Last active
August 29, 2018 10:56
-
-
Save markconroy/34dbf76b94a30a29424dcf5415e55894 to your computer and use it in GitHub Desktop.
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
{% set image_file_path = content.field_teaser_image[0]['#media'].field_media_image.entity.uri.value %} | |
{% set image_file_alt = content.field_teaser_image[0]['#media'].field_media_image.0.alt %} | |
<div class="teaser__image"> | |
{% if node.field_teaser_image_style.value == 'portrait' %} | |
<a href="{{ url }}"> | |
<img src="{{ image_file_path | image_style('portrait_teaser') }}" alt="{{ image_file_alt }}"> | |
</a> | |
{% endif %} | |
{% if node.field_teaser_image_style.value == 'landscape' %} | |
<a href="{{ url }}"> | |
<img src="{{ image_file_path | image_style('landscape_teaser') }}" alt="{{ image_file_alt }}"> | |
</a> | |
{% endif %} | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For my own reference, background to this snippet here https://www.annertech.com/blog/allow-editors-choose-image-style-drupal-image-fields