How to edit row content for Drupal 8 REST views

I am using Drupal 8 REST views. Each row has an image, and I would like to either add or edit an existing field inside the row in order to hold an encoded version of the image. I found a tutorial that shows how to include the raw image url.

When I try to edit the #markup section to be something like

'#markup' => 'TEST' . $style->buildUrl($image_uri),

the ‘TEST’ doesn’t appear in the JSON response. Does anyone have any recommendations on how I can either edit the contents of the row to be an encoded version of the image or how to add a new field to the row? I’m a beginner to Drupal Development, so any help/examples would be hugely appreciated.

Snippet from the tutorial:

foreach ($files as $delta => $file) { 
    $image_uri = $file->getFileUri(); 
    $elements[$delta] = array( '#markup' => $style->buildUrl($image_uri), );
 }

Not sure if I should instead edit the render function inside from within Serializer –  don’t understand how to access and edit the contents from within a row.

Thank you 🙂  Note: also posted on Stackoverflow

Drupal version: 


Source: https://www.drupal.org/taxonomy/term/4/feed