Score:1

How can I add the hero section image in the View to REST_API?

mt flag
  • Hello im using Drupal 9.5.9 version. How can I add the hero section image in the View to REST_API?

  • I have created an api with Rest_API to fetch data from Views I have created. I have no problem retrieving public data. However, I am getting "null"/"empty"/"id" errors when trying to get the image in the Hero Section in the View. I created two paths to get the images in the view, one to get all the views in the same category (jsonapi/news/) and the other to list the view whose id I entered (jsonapi/news/2775).

  • After adding Hero section from the Fields section in the View to get the image, I tried to get the img tags by making Rewrite results > Strip HTML tags to get the image link properly, but I'm still having problems.

    • When I list all views in the same category (jsonapi/news) enter image description here
    • When I list a single view (jsonapi/news/id)enter image description here
    • When I list a single view (jsonapi/news/id) with strip img tagsenter image description here
    • Another method I tried is Rewrite Results > Override the output of this field with custom text {% if field_hero_section %} <img src="{{ file_url(field_hero_section.entity.field_image.entity) }}" /> {% endif % } I filtered by trying this code, but the result I got is; enter image description here

How can i solve this ? Which method i should use ?

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.