I am attempting to use a custom pagemediaselect field I created in my page template.
The only problem is that the variable to output the field “{{p.header.lead_image}}” only outputs the file name of the media I select using the mediaselect field (ex: filename.jpg).
I thought maybe I could input THAT variable into this code to create the entire URL ( {{p.media[’{{p.header.lead_image}}’]}}, but that’s not working (I’m guessing you can’t use two variables together).
Could anyone point me in the right direction on how to remedy this?
Hi
Your solution is fine but your first attempt was the preferred option because its easier to read and maintain. You had the right idea just the wrong syntax.
Something like this will create the entire image tag and is also easier to use if you ever need to loop over a number of images to display them {{ page.media.images[ header.lead_image ].html( header.image_title , header.image_alt, 'my_static_class') }}
If you want to use title and alt fields you could add new fields to your blueprint or set them as static (or blank) fields with ‘’.