Last active
May 23, 2021 18:57
-
-
Save frankyonnetti/623110f3652854de6fb94f3849eda385 to your computer and use it in GitHub Desktop.
Drupal 8 - media image uri #drupal #d8 #media #img
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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