yireo / Yireo_Webp2

Magento 2 module to add WebP support to Magento 2
Open Software License 3.0
197 stars 57 forks source link

Remote storage issue #139

Closed webcreative24 closed 1 year ago

webcreative24 commented 1 year ago

Hello. We are running Magento 2.4.5 and using Minio (same as AWS s3) to store our media files, but unfortunately, we are getting errors while generating images. Does your extension support remote storage ? here is the error: Source cached image does not exists: /var/www/magento2/pub/media/catalog/product/n/e/new_project_-_2022-10-06t174801.724_2.png: array ( 'path' => '/var/www/magento2/pub/media/catalog/product/n/e/new_project_-_2022-10-06t174801.724_2.png',

Thanks

jissereitsma commented 1 year ago

No, this extension does not use any remote storage mechanism. This module depends on another package rosell-dk/webp-convert which can only convert images directly: https://github.com/yireo/Yireo_Webp2/blob/master/Convertor/ConvertWrapper.php#L41 Theoretically, this Yireo extension could fix this by wrapping a complete virtual filesystem approach around this, but I would say that it would then be better to have Magento first implement something like Flysystem.

Best solution currently would be to convert your images in the Minio bucket in the way you see fit - cron, manual, something - and disable the syncing option of this Yireo Webp2 extension. If the WebP file is uploaded, the extension still generates all relevant HTML tags from it.

webcreative24 commented 1 year ago

No, this extension does not use any remote storage mechanism. This module depends on another package rosell-dk/webp-convert which can only convert images directly: https://github.com/yireo/Yireo_Webp2/blob/master/Convertor/ConvertWrapper.php#L41 Theoretically, this Yireo extension could fix this by wrapping a complete virtual filesystem approach around this, but I would say that it would then be better to have Magento first implement something like Flysystem.

Best solution currently would be to convert your images in the Minio bucket in the way you see fit - cron, manual, something - and disable the syncing option of this Yireo Webp2 extension. If the WebP file is uploaded, the extension still generates all relevant HTML tags from it.

got it. thanks for your answer

webcreative24 commented 1 year ago

@jissereitsma Hello. Sorry, but probably off-topic, but maybe you know this problem and how it is solved. With the cache enabled, I open the page for the first time, then refresh again - there are no webp images. after clearing the Magento cache, the webp images are displayed. i.e. images are actually generated, but the user will not receive webp images until the Magento cache is cleared, thanks

jissereitsma commented 1 year ago

Yes, this makes sense. With the Full Page Cache enabled, the first time the page loads, it comes from the cache, so the HTML will not have included picture tags yet that replace original images with WebP images. If the Full Page Cache is cleared, only then the HTML will be generated, and with that the WebP extension will be called and the images are generated. This is normal Magento behaviour. The real important question is why there are normal images without WebP images and without a refresh of the cache in the first place.

For instance, if you are uploading a product and that product has a JPG image, then saving that product in the Magento Admin will cause the FPC to be cleared for that specific product (product page, category pages, possibly other pages). Next, if a customer visits that product page, the FPC entry is empty, so the page is generated, and the WebP extension will generate its images. And only afterwards, the new resulting HTML will be saved into the FPC.

If products are uploaded in a different way, or if images are updated in a different way, then there needs to be also an invalidation of the relevant FPC entries, otherwise the WebP images will never be generated.

Also note that the extension includes an option to create the WebP image right at the moment when Magento creates the original image. But with other extensions, this is easily bypassed.

webcreative24 commented 1 year ago

@jissereitsma got it. thanks

jissereitsma commented 1 year ago

I'm closing this issue as of yet. Feel free to reopen when this is still requiring a fix.