We have a headless Drupal 7 project that uses express and handlebars for it's front end. I'm experimenting with updating the backend to use Drupal 8.

I've created a REST export type view, but when you inspect it you see that for any image field you don't actually get a URL in the JSON.

field_logos: [
    target_id: "1",
    display: null,
    description: null,
    alt: "My Image",
    title: "",
    width: "83",
    height: "71"

I've done some research on this but can't find much documentation on this.

My first attempted fix was to change the view output format from entity to fields, and do as described in this thread. From that I can get a URI (again not a full URL path) but that screws my view up because it doesn't like multiple value fields, and won't nest anything so I get multiple rows with the same data.

During my googling I found this thread which describes how functionality has been added to Twig to deal with this (or at least a very similar) issue. Obviously I'm bypassing Twig altogether so that's not an option.

Maybe I need to look at a views preprocess function? I'm not sure how to do this for the REST export view type, so any help with that would be appreciated.

Why has this been left out of the JSON output, it seems quite crazy to me to have ALT text and width/height of the image but not the path to it here.

  • Are you sure this is not a bugreport?
    – Mołot
    Jul 10, 2015 at 17:05


Your Answer

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

Browse other questions tagged or ask your own question.