Skip to content

Instantly share code, notes, and snippets.

@frankyonnetti
Last active May 23, 2021 18:57
Show Gist options
  • Select an option

  • Save frankyonnetti/623110f3652854de6fb94f3849eda385 to your computer and use it in GitHub Desktop.

Select an option

Save frankyonnetti/623110f3652854de6fb94f3849eda385 to your computer and use it in GitHub Desktop.
Drupal 8 - media image uri #drupal #d8 #media #img
To get media uri, make sure view mode for field is set to "rendered entity"
```twig
{% set background_image_uri = file_url(content.field_photo_cta_photo[0]['#media'].field_media_image.entity.uri.value) %}
```
Get the media path in a view twig template
1. Add the image field to Relationships
2. Add "Media: Image" to fields with the relationship
3. May need the `background_image_uri` module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment