Get specific background image

Hi there.
I would like to set specific background-images and at the moment i can get the first image like this:
<div class="imagewide" style="background: url(<?php echo $page->image()->url() ?>) no-repeat center top;">

i changed the line, which causes a server error:
<div class="imagewide" style="background: url(<?php echo kirbytext($page->bigimage())->url() ?>) no-repeat center top;">
or
<div class="imagewide" style="background: url(<?php echo kirbytext($page->bigimage()->url()) ?>) no-repeat center top;">

Do I have to do a workaround? Place the variable in the stylesheet? Using $page->bigimage (which is the label) parses wrong.

Thanks in advance!

I suppose big image contains a filename

<?php
$image = $page->bigimage()->toFile(); 
?>
<div class="imagewide" style="background: url(<?php if($image) {echo $image->url(); } ?>) no-repeat center top;">

Yes it has. As it is in the txt:

Bigimage: (image: imagename-big.jpg)

but the url is empty now. (style=“background: url() no-repeat center top;”)
the image is in the same folder.

It does not make sense to use a kirbytag in such a field. I’d use an image field.

How to, without the panel?

Without the panel, just use the filename, without the tag.

bigimage: imagename-big.jpg

aah, didn’t know about this small detail! saves some other things now, too. :grin:

thank you very much!

1 Like