Well, i finally found the function i was looking for and it was pretty simple. All i had to do was to get all the fields field_info_instances()
with $entity_type
as the first parameter and then iterating over the result to get the widget type 'image_image' for ImageFields.
getting all ImageFields associated with a node
-
07-07-2023 - |
Frage
How do i get all the image fields attached to a content type on a full node without knowing the field names? Just out of curiosity, is there a way we can get all the fields of a specific type?
I am developing a module that needs image fields tied to a specific node and i'm using hook_node_view for fetching the node data.
I already viewed following post and it seems pretty relevant but i had difficulty understanding.
How to get the first image field from a node without knowing the field's name?
Lösung 2
Andere Tipps
This can be done by checking all the fields of your content type & check its "type" field
if the type field is a image you can render it
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow