yireo / Yireo_Webp2

Magento 2 module to add WebP support to Magento 2
Open Software License 3.0
194 stars 54 forks source link

Is compatibility to Magento 2.4.6 missing? #143

Closed BeenDelux closed 1 year ago

BeenDelux commented 1 year ago

Hey there,

we have updated to the latest Magento version: 2.4.6. Also updated all dependencies and also our PHP version.

Before that update we were running Magento on 2.4.4. Webp images were generated and working well.

After update to 2.4.6, the module and dependencies active and working, but the images still remain its orginal format like .jpg instead of converting.

Clearing cache and re-activate plugin does not work.

Is there a CLI Command to manually convert all images in? We think that the converter do not "restarting" once all "old" image files were converted.

PHP shows support for webp and also for all other formats. Also the latest version of the modules are running.

Hopeful that anyone has a solution.

Thanks in advance :)

dev-waltr commented 1 year ago

We ran into the same issue but in Magento 2.4.5.p1. (see pull request: https://github.com/yireo/Yireo_NextGenImages/pull/61)

It seems to be the missing normalizeUrl function call in the foreach loop of the isLocal function.

public function isLocal(string $url): bool
{
    $url = $this->normalizeUrl($url);
    if (!preg_match('#^http://#', $url)) {
        return true;
    }

    foreach ($this->storeManager->getStores() as $store) {
        $storeBaseUrl = $store->getBaseUrl(UrlInterface::URL_TYPE_WEB);
        if (strpos($url, $storeBaseUrl) !== false) {
            return true;
        }

        $storeMediaUrl = $store->getBaseUrl(UrlInterface::URL_TYPE_MEDIA);
        if (strpos($url, $storeMediaUrl) !== false) {
            return true;
        }

        $storeStaticUrl = $store->getBaseUrl(UrlInterface::URL_TYPE_STATIC);
        if (strpos($url, $storeStaticUrl) !== false) {
            return true;
        }
    }

    return false;
}
public function isLocal(string $url): bool
{
    $url = $this->normalizeUrl($url);
    if (!preg_match('#^http://#', $url)) {
        return true;
    }

    foreach ($this->storeManager->getStores() as $store) {
        $storeBaseUrl = $this->normalizeUrl($store->getBaseUrl(UrlInterface::URL_TYPE_WEB));
        if (strpos($url, $storeBaseUrl) !== false) {
            return true;
        }

        $storeMediaUrl = $this->normalizeUrl($store->getBaseUrl(UrlInterface::URL_TYPE_MEDIA));
        if (strpos($url, $storeMediaUrl) !== false) {
            return true;
        }

        $storeStaticUrl = $this->normalizeUrl($store->getBaseUrl(UrlInterface::URL_TYPE_STATIC));
        if (strpos($url, $storeStaticUrl) !== false) {
            return true;
        }
    }

    return false;
}
BeenDelux commented 1 year ago

Thanks, that worked for us.

jissereitsma commented 1 year ago

Thanks. This might have been a duplicate from the issues posted on the Yireo NextGenImages module, instead of this module. Could you please upgrade that module 0.4.0 to see if it fixes things?