8000 Webp-Express and Crop-thumbnails · Issue #48 · vollyimnetz/crop-thumbnails · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Webp-Express and Crop-thumbnails #48

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

Closed
bonakor opened this issue Nov 6, 2020 · 10 comments
Closed

Webp-Express and Crop-thumbnails #48

bonakor opened this issue Nov 6, 2020 · 10 comments

Comments

@bonakor
Copy link
bonakor commented Nov 6, 2020

Hello,
Someone in the Support page of WebpExpress proposed to add these line to /save.php, to make it compatible with WebP.
if(file_exists($currentFilePath . “.webp”)){ unlink($currentFilePath . “.webp”); } after line 73 of the save.php

I wanted to know what you think and if you had maybe a better idea to make your plugin compatible with WebP-Express.

Thank you :)

@vollyimnetz
Copy link
Owner

Hi @bonakor thank you for give me a note about this.
For the new version 1.3 i had a look into webp-express myself (i think i want to add the plugin to my normal tool-stack).
I think webp-express had changed the way they generate the webp-files since then. They now save the webp-images in a separate folder. Also it seems they use a direct filter whenever a file is cropped to update the webp-image.
So i think to further code is needed. At least i dont need no further code when testing version 1.3 of crop-thumbnails.

@bonakor
Copy link
Author
bonakor commented Feb 13, 2021

Yeah, I agree! Thanks for having a look.

@bonakor bonakor closed this as completed Feb 13, 2021
@bonakor bonakor reopened this Feb 26, 2021
@bonakor
Copy link
Author
bonakor commented Feb 26, 2021

I think, indeed, it's solved, but the remaining issue is that cropthumbnail doesn't clean the cached webp image.

@vollyimnetz
Copy link
Owner

Its not an good idea for crop-thumbnails to clean the cache of another plugin. The other image needs to be notified that a change has happend. I will have a look into that.

@vollyimnetz
Copy link
Owner
vollyimnetz commented Apr 7, 2021

rosell-dk/webp-express/issues/486

@benjibee
Copy link
Contributor
benjibee commented Sep 8, 2021

Hey @bonakor is this issue solved by WP 5.8 and native support for WebP thumbnail generation? A PR of mine (#54) was just merged that adds support for WP's native WebP (AVIF, etc.) support. Maybe have a look!

@phscam
Copy link
phscam commented Feb 28, 2022

For anyone that is looking for a quick fix:

As it depends on the configuration of WebPExpress where webp images are saved it's hard to delete the webp file. However, you can trigger a 'manual' conversion of the newly created crop.

class Hooks
{
    public function __construct()
    {
        $this->actions();
    }

    public function actions()
    {
        add_action('crop_thumbnails_after_save_new_thumb', [$this, 'convert_webp_for_new_crop'], 100);
    }


    /** 
     * Trigger new Webp conversion for new image crop.
     */
    public function convert_webp_for_new_crop($new_crop)
    {
        if (class_exists(\WebPExpress\Convert::class)) {
            // convertFile internally loads the config of WebPExpress and converts the specified file.
            // we can can call this method because at 'crop_thumbnails_after_save_new_thumb' the new crop is already saved to uploads.
            \WebPExpress\Convert::convertFile($new_crop);
        }
    }
}

For us it does exactly what we want: update the webp file of a newly cropped image :)

@pbov
Copy link
pbov commented Oct 24, 2022

@phscam this works for us, thanks!

I think this is a solution which can be integrated into @vollyimnetz great plugin.

@vollyimnetz
Copy link
Owner

I am currently filled up with work, but thanks for the reminder. As this change is not invasive, i will like to add the code. I will notify here once i integrated it in the code.

@vollyimnetz
Copy link
Owner

Will be in 1.5.0

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

No branches or pull requests

5 participants
0