The block fetched without img just title and alt, tha same for taxonomy (no taxonomy name)?
See original GitHub issueHi
I’ve created a block in Drupal then try to fetch its content (3 image fields with title and alt + taxonomy term) I’ve got the following data structure and I’ve got just title and alt no img the same goes for taxonomy term no taxonomy name
I’ve used getResource('block_content--basic', 'uid')
method to fetch the block.
{
"type": "block_content--basic",
"id": "a1e0df3f-88b8-4c04-859a-c5e8eb9z5b17",
"drupal_internal__id": 2,
"drupal_internal__revision_id": 2,
"langcode": "en",
"revision_created": "2022-03-31T15:51:08+00:00",
"revision_log": null,
"status": true,
"info": "Bagdes",
"changed": "2022-04-01T14:50:30+00:00",
"reusable": true,
"default_langcode": true,
"revision_translation_affected": true,
"body": null,
"links": {
"self": {
"href": "http://web/jsonapi/block_content/basic/a1e0df3f-88b8-4c04-859a-c5e8eb9z5b17"
}
},
"block_content_type": {
"type": "block_content_type--block_content_type",
"id": "48f76ec0-7c2a-4c91-a0dc-6f53434e3e92",
"resourceIdObjMeta": {
"drupal_internal__target_id": "basic"
}
},
"revision_user": null,
"field_acquia_drupal_7_certificat": {
"type": "file--file",
"id": "78148035-a610-4516-b02d-a14a3a10203d",
"resourceIdObjMeta": {
"alt": "Acquia Drupal 7 certification",
"title": "Acquia Drupal 7 certification",
"width": 147,
"height": 147,
"drupal_internal__target_id": 16
}
},
"field_acquia_drupal_8_certificat": {
"type": "file--file",
"id": "12cdc36a-e4ab-4830-aa60-481296b2a173",
"resourceIdObjMeta": {
"alt": "Acquia Drupal 8 certification",
"title": "Acquia Drupal 8 certification",
"width": 295,
"height": 295,
"drupal_internal__target_id": 18
}
},
"field_bagdes": {
"type": "taxonomy_term--achevements",
"id": "2cd66146-893f-4178-b092-10d88ff2b62f",
"resourceIdObjMeta": {
"drupal_internal__target_id": 1
}
},
"field_drupal_association_members": {
"type": "file--file",
"id": "449195da-beca-4151-b4ce-dc9f3b23aa05",
"resourceIdObjMeta": {
"alt": "Drupal Association membership",
"title": "Drupal Association membership",
"width": 217,
"height": 217,
"drupal_internal__target_id": 17
}
},
"relationshipNames": [
"block_content_type",
"revision_user",
"field_acquia_drupal_7_certificat",
"field_acquia_drupal_8_certificat",
"field_bagdes",
"field_drupal_association_members"
]
}
Please if someone can help because there is a native way using JS Promise to fetch the image that resides in this api route link but i think there will be another special next-drupal way to fetch the image as well.
Thanks in advance.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Image Alt Text vs. Title Text vs. File Names: What's the ...
What's the difference between image alt text, title text, and file names? Learn how to optimize each one for search.
Read more >Image SEO Options in Rank Math
How to Name Images and Optimize Images for SEO? ... Note: Rank Math adds missing ALT attributes only for images added in post...
Read more >H67: Using null alt text and no title attribute on img ... - W3C
If no title attribute is used, and the alt text is set to null (i.e. alt="" ) it indicates to assistive technology that...
Read more >How to Add Media Title and Alt Tags Automatically in WordPress
Optimizing your website for search engines like Google is difficult. You can simplify it with this guide to add media titles and alt...
Read more >register_post_type() | Function
When registering a post type, always register your taxonomies using the taxonomies argument. If you do not, the taxonomies and post type will...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Quick note: when you include the
field_badges
it will fetch all the fields for the terms. You probably care about a few fields only. You can do so as follows:You can fetch additional data (relationships or entity references in Drupal) using the “include” params.
~What is the name of the image field you want to fetch?
field_drupal_association_members
?~Update: added include for
field_acquia_drupal_7_certificat
.