Skip to content

Instantly share code, notes, and snippets.

@NikLP
Created March 24, 2017 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NikLP/3cc1c8f6734c9f9c6cbe18c8f8caf501 to your computer and use it in GitHub Desktop.
Save NikLP/3cc1c8f6734c9f9c6cbe18c8f8caf501 to your computer and use it in GitHub Desktop.
Paragraph field extraction
// paragraph text field actual text
{{ paragraph.field_title.value }}
// paragraph link field uri - internal:/ style (useless?)
{{ paragraph.field_link.0.uri }}
// content has this value - is processed, not validated (good in some cases)
{{ content.field_link[0]['#url'] }}
// paragraph image field uri
{{ paragraph.field_image.entity.fileuri }}
// actualised link for image field uri
{{ file_url(paragraph.field_image.entity.fileuri) }}
// nominal output for theming an image link with the above
{% if paragraph.field_link.0.uri %}
<a href="{{ content.field_link[0]['#url'] }}">
{% endif %}
<img src="{{ file_url(paragraph.field_image.entity.fileuri) }}"
alt="{{ paragraph.field_title.value }}" class="img-responsive" />
{% if paragraph.field_link.0.uri %}
</a>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment