Jump to content

Recommended Posts

Posted

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?

Posted

Hi @kaz

This one work for me

$image = $image->size(1600, 500)->httpUrl();
////
<div class="masthead masthead--<?= $template_name; ?>" style='background-image:url(<?= $image; ?>)'">

 

  • Like 1
Posted

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?

Posted
<div style="background: #999 url(<?php echo $page->myimage->httpUrl; ?>) no-repeat center"></div>

That should work

  • Thanks 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...