I’m trying to add a option for a custom banner image to our blog posts. Reading through the widget documentation, it seems like that would do the trick:
I’ve added an image_src widget to our single post template, which correctly displays an image selector when editing a post.
However, when I try to print the value in the single post or banner template, it’s empty.
Post Template:
{% module "blog_listing_featured_image"
path="@hubspot/image_src",
label="Listing Featured Image",
export_to_template_context=True,
no_wrapper=True
%}
<div style="display:none">{{ content.widgets.blog_listing_featured_image.body.value }}</div>
Banner Module Template:
{% set topic_posts = blog_recent_topic_posts( 'default', 'featured', 1 ) %}
<header class="banner {% if is_listing_view %}{% else %}banner--single-post{% endif %}"
{% if topic_posts and is_listing_view %}
{% for topic_post in topic_posts %}
{% if topic_post.widgets.blog_listing_featured_image.body.value %}
style="background-image:url('{{ topic_post.widgets.blog_listing_featured_image.body.value }}')"
{% else %}
style="background-image:url('https://website.com/hubfs/Banners/Blog%20Default%20Banner%20Image_02.png')"
{% endif %}
{% endfor %}
{% elif module.banner_image.src %}
style="background-image:url('{{ module.banner_image.src }}')"
{% else %}
style="background-image:url('https://website.com/hubfs/Banners/Blog%20Default%20Banner%20Image_02.png')"
{% endif %}>
...
</header>
...
Any help would be appreciated!