Hi, I have added a field for an image upload for a background image for an element on my webpage. When i type into the txt file ‘image.jpg’ it loads fine. However after uploading a new image in panel a ‘-’ is added before file name:
Here is my HTML: <div style="background-image:url(./home/<?php echo $page->HeroBackground() ?>)">
Here is my YML: HeroBackground:
type: files
headline: Hero Background
max: 1
template: cover
After changing image in panel this is what is shown in the browser: <div style="background-image:url(./home/- image-2.jpg)">
Chaining syntax like above is not a good idea, always use an if statement like in the documentation to check if the image exists before calling the url() or any other class method.