$asset = new asset('file.jpg');
$thumb = $asset->thumb(array('width' => 250));
then I use $thumb->url() inside an image tag src attribute.
Now all seems ok, the generated code is correct, but the thumb isn’t loaded the first time the page loads, even though web inspector shows a HTTP200 status code for the thumb. Only after a page refresh it is loaded. On hovering over the source in web inspector, it prints ‘could not load the image’.
The thumb has an img src pointing to the media/assets/ folder, where it is put by Kirby after creation. Possibly the page is requesting the image before it is ready? This also explains why it is actually found after a reload.
Since literally thousands of crude image files need to be resized on the fly, I’m pretty much stuck.
I dropped the code in the default template of the plainkit, exact same behaviour.
No plugins, just the plainkit and these lines of code added, I also added the dir and the file, of course. Nothing else.
Image sizes are very normal, ranging somewhere under a 800px width and less in height and are around 70kb filesize. Happens both with single and multiple images on the page. No caching is active on the system.
The same problem (or bug?) also shows in the Panel. If I open an image belonging to a page, the image box initially stays empty. If I click the empty box the browser tries to open the image and shows the following error message:
The image “path/filename” cannot be displayed because it contains errors.
The path/filename is the generated path by Kirby; media/etc
But after a page refresh also here it works, now the image loads. I changed from GD to Imagick, to no avail. It has all the seeming of a bug which only rears its head in specific circumstances.
I’m upgrading from a Kirby 2 site which is running without any problems on this server, so I doubt there might be something wrong with the apache/php7.3 config, but I’ll check that too. Suggestions are very much appreciated!