I have a css file that links to images.
.test{
background: url(http://site.com/dynamic/test.jpg) no-repeat;
}
These images however are dynamic. They change by the minute so I have to generate them and serve them with php. This means I don't save them to the public folder. I just serve them directly from the php script.
The problem is when I visit the php script (http://site.com/dynamic/test.jpg
), it generates the image correctly and I can see it in the browser, but when the same url is used in the css file as I need, the css can't seem to access the images.
I think it's because the image isn't saved in the public folder and is delivered by php which means that image has to be directly called to be generated, and calling the css file doesn't actually hit the php script (image url).
Does anyone have ideas to solve this problem?
Try to return Content-type using php header function
header("Content-type: application/force-download");
header('Content-Type: application/octet-stream');
header('Content-Type: image/jpeg'); // or png...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With