Stop checking Pageimage file when webpOnly option is true
When want to create only webp file, processwire still continue to check filesystem for create new variation. This process making page render to slow.
On this line: https://github.com/processwire/processwire/blob/3cc76cc886a49313b4bfb9a1a904bd88d11b7cb7/wire/core/Pageimage.php#L877
Its not checking webpOnly option and webp file exist or not ?
I added small fix : https://github.com/processwire/processwire/blob/3cc76cc886a49313b4bfb9a1a904bd88d11b7cb7/wire/core/Pageimage.php#L873
if ($options['webpOnly'] && $filenameFinalWebp) {
$filenameFinalExists = $filenameFinalWebp;
}
This method not removing webp variations
$image->removeVariations();
Should we use filedata for store and follow Pageimage variations instant of checking filesystem ?
if both of configs are true
$config->imageSizerOptions('webpAdd', true);
$config->imageSizerOptions('webpOnly', true);
its breaks admin thumb creation
@trk I'm not the original author of the webpOnly option (Horst is), but I think it's something meant to be used internally for specific cases and isn't part of the public API. PW won't maintain only webp versions of images, and I think the option is for cases where we know it only needs to manipulate a webp file and should leave the corresponding non-webp file as-is (if I remember correctly). Webp files are considered "extras" (PagefileExtra) rather than variations, though both originals and variations can have extras. You probably already have this but here are posts from the PW site with some examples of the public API for using webp images:
- https://processwire.com/blog/posts/webp-images-in-pw/
- https://processwire.com/blog/posts/webp-images-on-an-existing-site/
- https://processwire.com/blog/posts/webp-images-and-more/
I read these blog posts when you publish them
The problem is using only webp files. Examples on blog posts always use webp with jpg variations. If you want use only webp format there are problems.
@ryancramerdesign can you make a test on your side, set config vars
!!! Admin thumb creation won't work after these config vars
$config->imageSizerOptions('webpAdd', true);
$config->imageSizerOptions('webpOnly', true);
After that you will see system always checks and try to create webp variations, its not important file exist or not. This make page request slow
1 - System try to create webp file again and again 2 - Admin thumb creation not working
After add small fix on Pageimage, if webp file exists system not trying to create webp file
if ($options['webpOnly'] && $filenameFinalWebp) {
$filenameFinalExists = $filenameFinalWebp;
}
and if I add config vars inside ready.php by checking template file, admin thumb creation works
if ($page->template->name != 'admin') {
$config->imageSizerOptions('webpAdd', true);
$config->imageSizerOptions('webpOnly', true);
}
Now I am using latest master version of ProcessWire, but I modified Pageimage.php for performance