kaz Posted March 26, 2021 Posted March 26, 2021 I can't get that background images work. An example of two situations in default template: Once the image as a simple image - that works: <img src="<?php echo $page->myimage->httpUrl; ?>" alt="<?php echo $page->myimage->description; ?>"> And then the image as background image - unfortunately that doesn't work: <div style="background: #999 url('<?php echo $page->myimage->httpUrl; ?>') no-repeat center"></div> The path of the images is correct, the source code is fine, no matter if I use 'url' or the full path 'httpUrl'. How to build a background image from a defined image field, for example myimage?
Zeka Posted March 26, 2021 Posted March 26, 2021 Hi @kaz This one work for me $image = $image->size(1600, 500)->httpUrl(); //// <div class="masthead masthead--<?= $template_name; ?>" style='background-image:url(<?= $image; ?>)'"> 1
kaz Posted March 26, 2021 Author Posted March 26, 2021 Thanks @Zeka I don't understand the code, in what context is the size line above the div tag? Where does this line belong? I am a newbie, I don't understand the connections so far, belongs the line also in the template?
Zeka Posted March 26, 2021 Posted March 26, 2021 <div style="background: #999 url(<?php echo $page->myimage->httpUrl; ?>) no-repeat center"></div> That should work 1
kaz Posted March 26, 2021 Author Posted March 26, 2021 awesome, it works! Thanks for your continued patience!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now