Get an image source from a blog post's banner module into the listing template
SOLVE
Hi,
I have an image field within our blog posts teamplate banner module. I can get this displaying fine within the module template using {{ module.banner_image.src }} however I'm unsure how I would get this image on the listing template within the loop. I'm assuming I need to reference the specific module and then the field followed by srcbut I'm just not sure what the syntax is for this, I have tried
Get an image source from a blog post's banner module into the listing template
SOLVE
@benji_thecroc - Right, you can do that using the image src HUBL tag. Put it right into your blog template code. Then read that value in your listing template.
Aug 22, 20188:42 AM - edited Aug 22, 20188:46 AM
Contributor | Gold Partner
Get an image source from a blog post's banner module into the listing template
SOLVE
Hi,
Unfortunately it's not added to the module via HubL so I can't add in that attribute it seems, I've attached some screenshots. The image field is added to a custom module and it's then just displayed via HubL language. It's not implemented purely through HubL.
So we have a custom module acting as a blog posts banner. We then wanted a method of uploading a thumbnail image to be used as a mobile version of the featured image as the desktop versions aren't suitable for the mobile layout due to featured images have a landscape orientation and no amount of positions or cropping will make those suitable for a 1;1 ratio square on mobile. So I implemented an additional 'mobile_thumb' field within the custom banner module. I was hoping we could pull the field from the custom module and display in the listing view.
Get an image source from a blog post's banner module into the listing template
SOLVE
@benji_thecroc - ahh, you can't really share context between modules. Your best bet is to bake the banner right into the blog template with HUBL instead of using the custom module.
Get an image source from a blog post's banner module into the listing template
SOLVE
@benji_thecroc - Right, you can do that using the image src HUBL tag. Put it right into your blog template code. Then read that value in your listing template.
Aug 22, 20188:59 AM - edited Aug 22, 20188:59 AM
Contributor | Gold Partner
Get an image source from a blog post's banner module into the listing template
SOLVE
The blog post template is built using the template builder. I'm assuming I would I clone the template to HTML then add in the image src HUBL tag.
The only issue I can see here is how would a user then add this image in when creating a post if this image is hidden/not viewable on the post page itself. This image is used purely for the post listing template but should be specific to each blog post.
Get an image source from a blog post's banner module into the listing template
SOLVE
@benji_thecroc - You could actually add that HUBL code to the head or footer of your template and when the blog creator is creating a post, there will be a module in the left column where they can change this image.
Then, in your blog listing template, just add the extra info in the loop to find that HUBL widget data.