I have a REST Export view display setup in Drupal 8, delivering node fields.

The challenge: I want to theme/tweak/alter the output of JSON or HAL_JSON for and image field. Currently, it's rendering this in JSON:

"field_feature_image":"  <a href=\"http:\/\/mysite.com\/app\/sites\/default\/files\/images\/feature\/huygens.jpg\"><img src=\"http:\/\/christopherstevens.cc\/app\/sites\/default\/files\/styles\/large\/public\/images\/feature\/huygens.jpg?itok=cmIzLkJp\" width=\"480\" height=\"480\" alt=\"Huygens Probe (Illustration)\" typeof=\"foaf:Image\" class=\"image-style-large\" \/>\n\n<\/a>\n"

I would prefer it to look like this (taking out all the HTML):


Where's the best place to start? I don't see any views theme options when specifying a REST Export display. Should I create a module of some sort? Is there a theme option?

1 Answer 1


Here's one option:

Add a new relationship in the view for the field (field_feature_image in your case)

Add new field for "File: URI" using this new relationship

Use the File URI formatter, and also enable the "Display the file download URI" option

This method may not be ideal for fields with multiple values. I am still working out the best method to do that using the core tools in Drupal 8.

  • This works for me, for now. I'll mark this as the answer. Thanks! Commented Nov 9, 2015 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.