Skip to content

Instantly share code, notes, and snippets.

@labmorales
Created July 9, 2021 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save labmorales/26e5194a59a48c677b7463ecd027d366 to your computer and use it in GitHub Desktop.
Save labmorales/26e5194a59a48c677b7463ecd027d366 to your computer and use it in GitHub Desktop.
How to make WP Crop Thumbnails plugin and Webp Express work together
<?php
function convert_webp_crop_thumbnail($fullFilePath, $imageSizeName, $sizes) {
if (defined('WEBPEXPRESS_PLUGIN')) {
\WebPExpress\HandleUploadHooks::handleMakeIntermediateSize($fullFilePath);
}
}
add_action("crop_thumbnails_after_save_new_thumb", "convert_webp_crop_thumbnail", 10, 3);
@ant0nioli
Copy link

ant0nioli commented Jun 21, 2022

Hi @labmorales ! This is something I'm very interested in.

As I understand this if for this cropping plugin:

https://github.com/vollyimnetz/crop-thumbnails

I have tried your code but I don't get any change, the image keeps uncropped. Do you have any advice?

Thanks.

EDIT:
Solved. It was apparently related to WP Super Cache.
In WP Super Cache's ADVANCED tab I had to set:

  • Cache Delivery Method = EXPERT
  • And in the Mod Rewrite Rules section click the Update Mod_Rewrite Rules button

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment