Aug 18, 202011:15 AM - edited Aug 18, 202011:16 AM
Contributor
Show values of image with "export_to_template_context=True"
SOLVE
Hi HubSpot-Community
In my single-blog template i use "export_to_template_context=True" for an image tag. I need to use this image inside the blog loop to use this as the preview image. How can i access the url and alt values of this tag?
Thank you for your help. Sorry i dont really get it. The default modules i understand perfectly. But how can i access a export_to_template_contect value in a script? I cant really find that information in the documentary.
Show values of image with "export_to_template_context=True"
SOLVE
S,
EDIT: I realized you guys were speaking in reference to blog listing pages. My situation is a typical lp or webpage template. Apologies, didn't mean to hijack this thread. However if you do have any thoughts on my problem id appreciate any input.
Can you confirm that your solution does these two things, I ask because I've have reocurring issues with this functionality and support hasn't provided a clear answer.
1. Set a default image for the image module when a page is built using a template with this code on it.
2. That image be editable on the page level.
The issue i've run into over and over again is calling the value of the image module. The problem I run into is in order to have the default image load as a background image url I use the call:
{{ widget_data.background_image.src }}
Where background_image is the name of the module. This loads my default src value set in the code great. But once a page is built and someone uses that module to pick a new image it does not load the new image unless the code is more specific like this:
{{ widget_data.background_image.img.src }}
But having that value in the code breaks the usage of the default image src being set. So what im running into is i basically cannot set a default value for the image module AND it actually be editable by the end user.
Show values of image with "export_to_template_context=True"
SOLVE
Hi jau,
I know your question is over a year old, but I ran into the exact same problem (on a blog post template, though, but this should make no difference). For anyone reading this, I solved it with a simple if...else statement.
background-image: url('{% if not widget_data.blogpost_header_image.img.src %}{{ widget_data.blogpost_header_image.src }}{% else %}{{ widget_data.blogpost_header_image.img.src }}{% endif %}');"