Hello Gurus,
I have a REST Export view display setup in Drupal 8, showing node fields. It's AWESOME.

The challenge: I want to theme/tweak/alter the output of JSON or HAL_JSON. 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):

...
"field_feature_image":"http:\/\/mysite.com\/app\/sites\/default\/files\/images\/feature\/huygens.jpg"
...

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?

Thanks for taking a look. I'll answer if I find the solution first. :D

Comments

wessel@techtribe.nl’s picture

Same as: https://www.drupal.org/node/2672872

This helped for me: http://drupal.stackexchange.com/questions/162310/how-do-i-override-theme...

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

GiorgosK’s picture

No need for custom coding for sending image URL instead of HTML
https://www.drupal.org/project/image_url_formatter

------
GiorgosK
Web Development