Skip to content

Instantly share code, notes, and snippets.

@skippednote
Last active August 15, 2017 11:08
Show Gist options
  • Save skippednote/5c1d9776b4f2aea8e51ffa99bbc01b68 to your computer and use it in GitHub Desktop.
Save skippednote/5c1d9776b4f2aea8e51ffa99bbc01b68 to your computer and use it in GitHub Desktop.

Paragraph

  • Image
    • image_style: field_machine_name.0['#image_style']
    • alt: field_machine_name.0['#item'].alt
    • uri: field_machine_name.0['#item'].entity.fileuri

 Example

{% include "@molecules/01-newsletter/newsletter.twig" with
  {
    'title': content.field_news.0['#text'],
    'image_src': content.field_newsletter_image.0['#item'].entity.fileuri | image_style('thumbnail'),
    'image_alt': content.field_newsletter_image.0['#item'].alt,
    'link_src': content.field_newsletter_lin.0['#url'],
    'link_text': content.field_newsletter_lin.0['#title'],
  }
%}
<div class="newsletter">
  <div class="newsletter--top">
    <img src={{ image_src }} class="newsletter__image" alt="{{ image_alt }}">
  </div>
  <div class="newsletter--bottom">
    <h2 class="newsletter__title">{{ title }}</div>
    <a href="{{ link_src }}">{{ link_text }}</a>
  </div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment