-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Description
Short description of the issue
When I resize a PNG image to it's original size and ask for the WebP url, no WebP file is generated but a newly generated PNG URL is returned. Interestingly, this is only happening with PNG, not JPG.
Example: I upload a PNG image of 1280x800
$page->image->webp->url
➝ filename.webp ✔️$page->image->width(800)->webp->url
➝ filename.800x0.webp ✔️$page->image->width(1281)->webp->url
➝ filename.1281x0.webp ✔️$page->image->width(1280)->webp->url
➝ filename.1280x0.png ❌
I tried many variants with webp()
, url(false)
, different config settings for webp ... Original Forum Post
Expected behavior
I expect a WebP file to be generated and a WebP url to be returned.
Actual behavior
No WebP file is generated but a url to a newly generated PNG is returned.
When I set useSrcUrlOnFail
to false
inside $config->webpOptions
, the webp url is returned, but the file is not found. This indicates to me the creation is tried but fails.
Optional: Suggestion for a possible fix
Just a possible workaround on template level:
if($image->width == $width) {
$url = $image->webp->url;
} else {
$url = $image->width($width)->webp->url;
}
echo "<img src='{$url}' />";
Steps to reproduce the issue
- Setup Processwire, create
image
field in home template - upload a png file and remember it's original width
- In home.php template:
echo "<img src='{$page->image->first()->width(640)->webp->url}' />";
(where 640 needs to be the original width) - observe the png output and no generated webp file in /site/assets/files/1/. If you increase or decrease width by 1, a webp file will be created and the correct webp url will appear. If the same is done with a JPG, it works as expected.
Setup/Environment
- ProcessWire version: 3.0.148 and 3.0.160 dev
- PHP version: 7.2.4
- GD Lib "bundled (2.1.0 compatible)"