BuddyDev

Search

[Resolved] ewww image optimizer support?

Tagged: ,

  • Participant
    Level: Initiated
    Posts: 14
    Andy on #9577

    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,
    Andy

  • Participant
    Level: Initiated
    Posts: 14
    Andy on #9578

    Guys one thing to note, there is a typo in the callback function name in that linked code snippet above (‘eww’ vs ‘ewww’). But even after I fixed that, it still isn’t working. Have the hook names changed maybe?

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #9589

    Hi 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.

  • Participant
    Level: Initiated
    Posts: 14
    Andy on #9600

    Thanks Brajesh, I really appreciate your help.

    I also emailed the developer of ewww and will update if I find out anything helpful from him.

    • This reply was modified 7 years, 6 months ago by Andy.
  • Participant
    Level: Initiated
    Posts: 14
    Andy on #9636

    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.

  • Participant
    Level: Initiated
    Posts: 14
    Andy on #9637

    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, 6 months ago by Andy.
  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #9641

    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.

This topic is: resolved