Unfortunately the div does not display anythingā¦which means that the background-image does not load, right? ⦠But when I look into the source code, the URL is correct.
Its possibly the z-index: -500;. They should start from 1. Negative numbers put it behind the page. Its also a large image, so you need a screen larger then 1280px by 1024px to see it repeat.
Why not do it on the body element instead? Using empty tags for things like this is bad practice.
The width and height also needs to be in the style attritbute, not as properties on the div. It might be because it has no height.
The body tag is a required tag, and the way you had it means the page will only get an opening body tag if the image is available. If itās not, then you will end up with invalid HTML.
Aaaah, I see what you mean! Making the body dependable is a really, really bad idea⦠haha
@texnixe Unfortunately, your last code did not work for me. Donāt know why.
I wrote it like this, and now logically, if there is no image for the background-image-code, there is an else in which the body-tag gets executed either way.
Yes, that works and looks like eloquently written code.
Thank you both very much! Most appreciated.
EDIT: I noticed that NOT the first image⦠that was uploaded to the page panel⦠gets selected and displayed, BUT the first image that comes first alphabetically, and numbers before letters . So image '1abc.jpg' gets selected, rather than 'acb1.jpg'. [!] It does not matter in what order they appear in the page panel.
To truly select the image that is at the top of the panel image-upload-list⦠I added a sortBy⦠$image = $page->images()->sortBy('sort','1')->first())? $image->url() :
Should be sortBy('sort', 'desc') or sortBy('sort', 'asc'), passing the string 1 as second parameter doesnāt make sense.
And yes, if you manually sort image in the Panel, you have to also sort them in the frontend, otherwise the standard sort order is the order in the file system.