I want to populate a hero block using a background image from a node field. I don’t want the user to interact with Layouts at all. 

So the client creates a node (of content type ‘Section’) and uploads an image to ‘banner’ field. My layout uses a hero block, but my custom hero block tpl.php doesn’t know about $node. 

How can I get the banner image field values into my template? Does this require a preprocess function? And would it be easier just to build a View block with a Nid relationship?

Thanks

Accepted answer

Have you looked at the BG Image Formatter

https://github.com/backdrop-contrib/bg_image_formatter

Most helpful answers

You could also try Current Content Display Block which with a bit of config and CSS could get you what you need.

Hi Jim

Take a look at Smart Blocks and see if that does what you need

Comments

Thanks people. I went ahead and created a View block using the BG image formatter. 

I might still end up messing with template files because I’ll probably need to overlay a graduated tint to make sure the title is always readable (clients always choose inappropriate pics don’t they!) but this works well enough to get on with the rest of the site.

Hi Jim...,

I did something similar for a new site ive created parallax-news.com where the poster can add an image and a blue background with text shadows to make text more readable.