- Issue created by @Nelo_Drup
- πΊπΈUnited States bobbysaul
Hello,
I guess it would depend on how you are rendering the image. I would recommend the Twig Tweak module and use one of the filters provided with that module, drupal_image β or image_style filter β .
Something like one of the following should work:
<img src="{{ node.field_media.entity.field_media_image|file_uri|image_style('thumbnail') }}" />
{{ drupal_image(node.field_media.entity.field_media_image|file_uri, 'thumbnail') }}
I do it more or less this way:
[paragraph:field_tipparr_tipbloq_reshom_img]
And yes it works for me but how could I do the same with twig because I only get errors or where did I add the styles?- πΊπΈUnited States bobbysaul
Using the token
[paragraph:field_tipparr_tipbloq_reshom_img:[image style machine name here]]
will return the url to the image with the image style specified on it. For example if your image style is "medium" something like this would render the image:<img src="[paragraph:field_tipparr_tipbloq_reshom_img:medium]" alt="[paragraph:field_tipparr_tipbloq_reshom_img:alt]" />
You can see your image styles at /admin/config/media/image-styles assuming the image style module is installed.
If you want to do the same thing but with twig instead of tokens you can do something like this:
<img src="{{ paragraph.field_tipparr_tipbloq_reshom_img|file_uri|image_style('medium') }}" alt="{{ paragraph.field_tipparr_tipbloq_reshom_img.alt }}" />
- πΊπΈUnited States bobbysaul
The same can also be done with the Twig Tweak view filter β as such:
{{ paragraph.field_image | view({settings: {image_style: 'medium'}}) }}
- Status changed to Postponed: needs info
about 1 year ago 3:19pm 14 October 2023 - πΊπΈUnited States bobbysaul
Hello @Nelo_Drup. Did the above suggestions work for you? Is there any work that needs to be done for this issue?
- Status changed to Closed: works as designed
about 1 year ago 10:48pm 19 October 2023