Getting image widget source

I have the following line of code on my blog post template

{% image "listing_image" label="Listing image", export_to_template_context=True %}

The featured image on a blog post is used in the hero section. I have created this image widget so that a user can select a smaller image that can be used on the listing template.

To get the above widgets value, I’m doing the following:

{% for content in contents %}
{{ content.widgets.listing_image.body.value.src }}
{% endfor %}

However, the value it returns is empty. I have also tried:

{{ content.widgets.listing_image.body.value }}

Same results, it is empty.

How do I get the value of the widget on my post template and use it on the listing template?

@Amit_95 Try :

{{ content.widget_data.listing_image.src }}

Hi amwilie,
Having what you suggested (below) didn’t work for me either. The below returned nothing for me

{{ content.widget_data.listing_image.src }}

For reference, here is my blog post with a listing image populated. This post is published and updated so it should have a value.

On my listing page, I have the following:

But when inspecting that blog post card on the listing page, I see this:

No value seems to pull through

Hi @Amit_95, you just need to keep the body:

{{ content.widgets.listing_image.body.src }}

If you’re not getting the result/data you expect it’s sometimes helpful to console log a part of a method/dict which will help you find the structure you need to get what you want. e.g. the below will console log the widget data which you can then read to find out which object src is in.

<script>
 console.log(`{{ content.widgets.listing_image }}`);
</script>