Jump to content

How to insert background image


kaz
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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