I want to include Magnific Popup in my site. The only thing that left to do is display the URL of the image in link wrapping the image field.
I saw that image.html.twig
modify the image of my articles. So, the override works but when I try to use some variables it just don't work (only atributtes and style_name are allowed).
What can I do if I want to display the URL of $var['elements']['field_image']['#blazy']['_uri']
(Kint)?
Here is the twig template that I trying to modify:
{#
/**
* @file
* Theme override of an image.
*
* Available variables:
* - attributes: HTML attributes for the img tag.
* - style_name: (optional) The name of the image style applied.
*
* @see template_preprocess_image()
*/
#}
<a href="#" class="popup-img"><img{{ attributes }} /></a>
UPDATE: If I try to use {{ attributes.src.__toString() }}
as advised in comments of this post, I see this output, not the image data:image/svg+xml;charset=utf-8,%3Csvg xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg' viewBox%3D'0 0 640 257'%2F%3E
{{ attributes.src }}
? – sonfd Mar 8 '20 at 4:54{{ atributes.src }}
displaysdata:image/svg+xml...
not the link that I want. – renguer0 Mar 8 '20 at 5:00{{ attributes.src.__toString() }}
shows me the relative image URL. – No Sssweat Mar 8 '20 at 5:55data:image/svg+xml;charset=utf-8,%3Csvg xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg' viewBox%3D'0 0 640 257'%2F%3E
– renguer0 Mar 8 '20 at 6:25