Anonymous users can't access to image style field Entity


Type : block
Field : 'Reference to entity : image style' (field_image_style)
Manage display : I display the Entity ID




Twig

In my twig template, I get the field_image_style data from content.field_image_style.

Issue

Works great on admin user, but not when browsing the website as an anonymous user.

This is not a image style generation error, or a wrong permission to files folders : you can access to both original image and generated styled image on anonymous.

And this is where it gets weird. It's working when you give the "Administer image styles" permission to anonymous users.



Dump

Just to show you what result I have, here's a dump of content.field_image_style with an admin user :



And with an anonymous user :
The purpose of a field configured in a view mode is to render the output.

To process field values in code use the entity object. You'll find this in a block template in this variable:

$variables['elements']['content']['#block_content']


So in TWIG you can try to access the field value like this:

{%
  set style = elements.content['#block_content'].field_image_style.target_id
%}