Tagged: EWWW, mediapress
Hi there,
I have tried the code snippet previously suggested here (https://buddydev.com/buddypress/resizing-optimizing-photos-uploaded-by-mediapress/) and it is not working for me. EWWW is only optimizing resizes and is not optimizing the full size images.
Does the previously linked suggestion need updating?
Thanks,
AndyHi Andy,
Thank you for posting. We will need a day to test it. It might be due to recent changes in ewww.Thank you for catching the typo.
Hi again,
Shane from ewww suggested using ‘mpp_generate_metadata’ for the second hook and problem is solved!
Another thing I noticed is mpp_handle_upload looks like a filter hook, not an action hook. (See line 267: https://github.com/buddydev/mediapress/blob/master/core/storage/class-mpp-local-storage.php). I tried changing ‘add_action’ to ‘add_filter’ for the first hook, result seems the same. I guess as long as ewww_image_optimizer_handle_upload is returning what the hook expects it will be fine either way. But maybe good practice to use ‘add_filter’ here?
Here is the code I am testing now:
—
add_action( ‘init’, ‘mpp_ewww_optimizer_bridge’ );
function mpp_ewww_optimizer_bridge() {if( function_exists( ‘ewww_image_optimizer_handle_upload’ ) ) {
add_filter( ‘mpp_handle_upload’, ‘ewww_image_optimizer_handle_upload’ );
add_filter( ‘mpp_generate_metadata’, ‘ewww_image_optimizer_resize_from_meta_data’, 15, 2 );}
}
—Just tested with a 5120×3400 image upload and it successfully processed the original, resizing down to 1920px as specified in ewww settings, and compressed by 96%! So all seems to be working.
Hi again guys,
Confirmed with Shane from EWWW that the first hook should indeed be add_filter, as above. This allows EWWW to resize earlier and use less memory, and also ensures image rotation is handled properly for thumbnails. Shane said he is going to do some more testing and plans to include these 2 filters directly in a future version of EWWW.
- This reply was modified 7 years, 4 months ago by Andy.
Thank you Andy,
And my sincere thanks to Shane too.
will update the blog post with the correct code.Thank you.
The topic ‘ [Resolved] ewww image optimizer support?’ is closed to new replies.