Get source of image module is returning just default value

Hi Hubspot-Community

In a HubL Blog-Item theme i use an image module:

 {% module "intro_image" path="@hubspot/image" label='Intro-Bild', src='http://cdn2.hubspot.net/hub/428357/file-2117441560-jpg/img/dev-bg-compressed.jpg', export_to_template_context=True %}
 {{ widget_data.intro_image.src }}

Now i always get the default src (dev-bg-compressed.jpg). When i create a blogpost and change the default image to one inside the Media-Manager, the value is not chaning and i dont get back the src of the selected image in the Hubspot Media-Manager.

What am i doing wrong?

Thank you so much for your help and best wishes

Pascal

Hi Pascal @peesen ,

Does changing to this help?

{{ widget_data.intro_image.img.src }}

According to the docs on the image module , the img parameter is now what contains the source.

I have a feeling that will partially help, but I just had a quick try and I couldn’t work out how to set my own default image. As soon as an image is removed in the template by the end user, the object gets blanked and nothing is returned…

You can probably hack around that in the short term with a conditional in your template to return either the img.src or a default value if not set, but… not ideal. I may very well be missing something here though -- @alyssamwilie, @Mike_Eastwood: any ideas?

Please let us know how you get on with this, Pascal.

PS: I also noticed you’re using @hubspot/image for the path, but I don’t see that any more in the docs for some reason. Only /image-email and /linked_image - you could also try with linked_image perhaps?

Cheers,

Mike

---
Did I answer your question? If your question is answered, please mark it as a solution. If you need more help, hit that big orange ‘Reply’ button!

Hi @peesen

Not sure if you are building a Custom Module or using the standard module. I’d expect to see something like this in your code:

{% if module.image_field.src %}
	{% set sizeAttrs = 'width="{{ module.image_field.width }}" height="{{ module.image_field.height }}"' %}
	{% if module.image_field.size_type == 'auto' %}
		{% set sizeAttrs = 'style="max-width: 100%; height: auto;"' %}
	{% elif module.image_field.size_type == 'auto_custom_max' %}
		{% set sizeAttrs = 'width="100%" height="auto" style="max-width: {{ module.image_field.max_width }}px; max-height: {{ module.image_field.max_height }}px"' %}
	{% endif %}
	<img src="{{ module.image_field.src }}" alt="{{ module.image_field.alt }}" {{ sizeAttrs }}>
{% endif %}

You can see the HTML Image tag in this sample code snipped from above:

<img src="{{ module.image_field.src }}" alt="{{ module.image_field.alt }}" {{ sizeAttrs }}>

Can you see an image tage in yours?

Mike

Thank you for the tag @mike-ward