I am using the following code to dynamically generate a background image:
$image = imagecreatefromjpeg( 'FILENAME' );
header( 'Content-Type: image/jpeg' );
imagejpeg( $image );
Opera displays nothing when I try to view this script. Chrome and IE work fine, and if I add header( 'Content-Disposition: attachment; filename=download.jpg' );
Opera will download the image as expected (and the content is correct).
Is there a workaround for this, or some header that I am not setting? I am surprised that Chrome handles the image correctly, while Opera (Chromium-based) does not.
Update: the same problem is true if I use, e.g., Content-Type: image/png
and imagepng()
instead: loads in all browsers but Opera, and Opera downloads the file correctly.
Update': this is an extension problem, but I don't know why. Adding my site to the whitelist of uBlock makes everything work. My site has practically zero traffic and certainly doesn't spam anything, so this is odd.
In that case the cleaner solution would be just to put 'banner.php' in one of your images folder and put this in the .htaccess of the folder 'banner.php' is in:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}banner.php [NC,L]
(provided you have mod_rewrite loaded in Apache)
It checks if an image exists, if not it lets banner.php handle the job.
That way you can just use "banner.jpg" as the source and neither Opera or anyone else will know it's dynamically generated..