Showing posts with label image render on twig. Show all posts
Showing posts with label image render on twig. Show all posts

Thursday 6 September 2018

Media entity fields render in drupal 8 Node Twig template.

If we want to load media entity fields on node twig template. It's easy to load media entity, Please have a look..

{# call to media entity fields on node twig #}

{% for key, item in node.field_document_entity_browser %} 
// This is the node field which is connect to media field `field_document_entity_browser`..
{% if node.field_document_entity_browser[key].entity %}
// here we are rendering media entity field which machine name is `field_capt2120`..                           
{{ node.field_document_entity_browser.entity.field_capt2120[key].value }}

// here we are rendering media entity image field which machine name is `field_media_image`..        
{%if item.entity %}
{% set media = item.entity %}
{% set file = media.field_media_image.entity %}
{% set uri = file_url(file.uri.value) %}
                              
<img src="{{ uri }}" alt="{{ media.name.value }}" />
                          
 {% endif %}                           
                                                                                     
 {% endif %}
  {% endfor %}



Note: If have any suggestions or issue regarding 'Media entity fields render in drupal 8 Node Twig template.' then you can ask by comments.  

How to resolve max execution time error in drupal ?

When you found error regarding 'max_execution_time' exceed, then you can follow steps for resolve this error: Steps:   You can put t...