Score:1

How do I get the selected image style from a referenced media field?

cn flag

I created a custom block with an entity reference to a media field (field_background_image).
In the display settings I have chosen 'Thumbnail' as format and selected a custom image style 'background'.

In my _preprocess_block(&$variables) function I would like to get the selected format (thumbnail) and especially the selected image style ('background').
How can I load both these information from the $variables?

leymannx avatar
ne flag
`composer require drupal/devel_kint_extras && drush -y en devel_kint_extras && drush cr`: This enables the Devel module, flushes cache, and now you can put `ksm($variables);` inside your preprocess to inspect the variables, visit the page and see what you find in there.
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.