• Resolved toto

    (@toto)


    Hi is it possible to disable or bypass if is subfolder?

    For example:
    I have wp-content/uploads/slider/ I want to upload full image size in this folder not resized by (Resize Media Images – Max Width & Max Height) for all other folders images to be resized to max options.

    I tray to use:
    add_filter( ‘ewww_image_optimizer_bypass’, ‘ewww_skip_theme’, 10, 2 );
    add_filter( ‘ewww_image_optimizer_resize_dimensions’, ‘ewww_custom_resize’ );

    but no sucsess.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Shane Bishop

    (@nosilver4u)

    Adding a filter won’t work if the conditions aren’t right. The resize dimensions filter is definitely the one you want. The bypass filter only applies to compression, not resizing. So, what is the full code you tried?

    Thread Starter toto

    (@toto)

    Im using this code:

    // Bypass ewww_image_optimizer for ‘SLIDER’ CPT
    add_filter( ‘ewww_image_optimizer_resize_dimensions’, ‘ewww_custom_resize’ );
    function ewww_custom_resize( $dimensions ) {
    global $pagenow;
    if ( ( ‘async-upload.php’ == $pagenow || ‘media-upload.php’ == $pagenow ) && false !== strpos( wp_get_referer(),’post_type=slider’ ) ) {
    return array( 0, 0 );
    }
    return $dimensions;
    }

    And it works good!

    If you upload image in CPT – slider, this code skip default setting in ewww to resize images and upload it in full size. 🙂 For all other uploads ewww resize images to default settings (1000x1000px).

    But the code is not completed I need to make it, if you use bulk optimize all images – how to skip this folder ‘slider’. My CPT upload images in uploads/slider.

    Is there a way to bypass resizing for CPT or for specific folder?

    Thank you!

    Plugin Author Shane Bishop

    (@nosilver4u)

    I just realized it isn’t really possible to bypass resizing based on the filename. So for the next release, I’m adding a second parameter, which will be the filename.
    You would need to change your add_filter() call to this:
    add_filter( ‘ewww_image_optimizer_resize_dimensions’, ‘ewww_custom_resize’, 10, 2 );
    The 2 tells WP how many parameters your function expects. Then the function declaration needs to be like this:
    function ewww_custom_resize( $dimensions, $file ) {

    Then you can use strpos or preg_match on the $file variable, depending on whether you need to include/exclude sub-folders of the slider uploads folder.

    Plugin Author Shane Bishop

    (@nosilver4u)

    FYI, the updated filter is on github: https://github.com/nosilver4u/ewww-image-optimizer
    3.3 should be out in the next couple weeks otherwise.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Bypass resize in subfolder’ is closed to new replies.