Getting a custom block image field URL in the block Twig template
I have a custom block containing a text field and an image field. I would like to render the block so that the image's URL can be defined as a data attribute of the block's wrapper div so that it can be used by a javascript function to create a parallax background effect behind the text field. If I make a template file block.parallax.html.twig, I a...
How to find image style URL from within twig template?
I'm implementing a node template that uses an image twice; once in a 'normal' way (i.e. using the image style defined in the field's display configuration for that view mode), and the other is as a css background-image property. I need one of two things: (ideally) a way to get the URL for a different image style of the same image. a way to get the ...
How to retrieve image URL from Media Bundle field in Twig Template
I have created a custom media bundle using the Media Entity module. Here is a screen grab of the media bundle: I have created a Twig template media--image.twig.html I am able to retrieve all of the field values via the content variable in Twig but I'm having difficulty retrieving the field_image URL. Here is a snapshot of the output from {{ kint(co...
How to access url of Remote Video, Document and Image inside twig template?
I have a field called Media (machine name: field_media) inside of a content type. This field Media takes the media types of Remote video, Image, and Documents. I am currently trying to render this media inside my twig template as a link to whatever media type it is. For example, if it's a remote youtube video, the link would take you to the video o...