Skip to main content
edited body; edited tags; edited title
Source Link
leymannx
  • 18.8k
  • 6
  • 72
  • 126

How tocan I get the image url in a twig fileURL from a media entity in a node template?

Normally I am able to get an images urlURL by setting the display setting for that field to urlURL and then writing something similar to this in order to print the url

{{ content.field_image.0['#markup'] }}

However this is not possible in the display settings for a media entity, the only options are -

  • Rendered entity
  • Entity ID
  • Thumbnail
  • Label

So my question is how tocan I get the urlURL from the image, as I need to use the field as a background image so can't just render it out as normal.?

How to get image url in a twig file from a media entity

Normally I am able to get an images url by setting the display setting for that field to url and then writing something similar to this in order to print the url

{{ content.field_image.0['#markup'] }}

However this is not possible in the display settings for a media entity, the only options are -

  • Rendered entity
  • Entity ID
  • Thumbnail
  • Label

So my question is how to get the url from the image, as I need to use the field as a background image so can't just render it out as normal.

How can I get the image URL from a media entity in a node template?

Normally I am able to get an images URL by setting the display setting for that field to URL and then writing something similar to this in order to print the url

{{ content.field_image.0['#markup'] }}

However this is not possible in the display settings for a media entity, the only options are -

  • Rendered entity
  • Entity ID
  • Thumbnail
  • Label

So my question is how can I get the URL from the image, as I need to use the field as a background image so can't just render it out as normal?

Source Link
drupalhgy
  • 125
  • 6
  • 14

How to get image url in a twig file from a media entity

Normally I am able to get an images url by setting the display setting for that field to url and then writing something similar to this in order to print the url

{{ content.field_image.0['#markup'] }}

However this is not possible in the display settings for a media entity, the only options are -

  • Rendered entity
  • Entity ID
  • Thumbnail
  • Label

So my question is how to get the url from the image, as I need to use the field as a background image so can't just render it out as normal.