Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webp images not being generated if cached jpg does not exist yet #70

Open
indykoning opened this issue Mar 23, 2021 · 12 comments
Open

Webp images not being generated if cached jpg does not exist yet #70

indykoning opened this issue Mar 23, 2021 · 12 comments

Comments

@indykoning
Copy link

Magento: 2.4.2
nextgenimages: 0.2.1
webp2: 0.10.5

When the media/catalog/product/cache folder is completely empty only Magento placeholders will be visible.
I think this is because the original jpg does not exist yet.

When i open the image location in a new tab and change .webp to .jpg i'll get the correct jpg.
After this the .webp will also be properly generated.

A possible fix may be checking if the .jpg exists, if not either trigger it to generate the jpg or don't return the webp file so the jpg will be generated by the user request.

@gtlt
Copy link
Contributor

gtlt commented Mar 30, 2021

I made a PR #74, it looks ok in dev mode.

@ssmadsen90
Copy link

ssmadsen90 commented Apr 2, 2021

I can confirm this error exists to.
Magento 2.3.6
PHP 7.3.25***
Mode: Production (Working in developer)

Edit: PHP 7.3.25

@jissereitsma
Copy link
Contributor

Thanks for reporting this. I hope to look into the PR shortly (next week).

@ssmadsen90 Hmm, are you really investing time into performance optimization, if your PHP version is this old and already removed from support by the PHP project since January last year? https://www.php.net/supported-versions.php Also note that PHP 7.1 is not supported by Magento, so it kind of makes sense to upgrade PHP ASAP instead of spending time on other optimizations https://devdocs.magento.com/guides/v2.3/install-gde/system-requirements.html#:~:text=Magento%20supports%20PHP%207.4.,is%20not%20tested%20or%20recommended.

@jissereitsma
Copy link
Contributor

And @gtlt thanks so much for the PR itself :)

@ssmadsen90
Copy link

@jissereitsma
My answer is edited, im running 7.3.25.

@jissereitsma
Copy link
Contributor

@ssmadsen90 Thanks for the update - sorry for being so picky about this, but with PHP 7.1 it would have seemed a waste.

@ssmadsen90
Copy link

@jissereitsma No need at all. Thanks for paying attention to it :-)

@jissereitsma
Copy link
Contributor

@gtlt The PR is committed and a new release is made.

Everyone, could you test this?

@ssmadsen90
Copy link

@jissereitsma
On it :-)

@ssmadsen90
Copy link

@jissereitsma Seems working here 👍

@mdkdev
Copy link

mdkdev commented Jun 20, 2022

@ssmadsen90 @gtlt @jissereitsma,

Running on:

  • Magento 2.4.4
  • PHP 8.1
  • NGINX
  • Developer/Product mode.

I don't think the original question / bug isn't resolved yet. When you flush your catalog images cache (so the cache folder is cleared) and you clear your cache once, the images on the frontend are served in the original file format instead of serving the WebP images. When you have full page cache enabled, varnish will serve the output and the logic of generating the WebP images will never be triggered again. The fact that the WebP generation works, is because the cache files are being generated while saving the images in the backend and the cache keys of the corresponding categories and product are being cleared. I don't know if this is something that should be fixed, or that we just have to leave the "Flush Catalog Image Cache" button alone :)

@jissereitsma
Copy link
Contributor

This ticket has gone cold.

To maybe reiterate, the following story might simulate the same issue: First of all, the Full Page Cache would need to be enabled (with or without Varnish) and a specific page (like a category page) would need to be reloaded, so that the cache is warm. Next, the folder pub/media/catalog/product/cache/ needs to be wiped out. The result is that the category shows only dummy images (because no images exist). Next, the command bin/magento catalog:images:resize can be run to regenerate the original JPG images. At this moment, the JPG images are there, but the WebP images are not. However, when the page cache expires, the page will be regenerated and then the WebP images will be generated again.

Isn't therefore it more logical to say that the image generation command should also generate WebP images? Unfortunately, that's not easy to do. And it raises the question whether it is not smarter to generate all WebP images offline by using another (faster) tool (like something based on Node). My 50 cents after 2 years.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants