• Resolved refinedigital

    (@refinedigital)


    I’d like to suggest an opportunity in the Code to apply a Filter so we (developers) can fine tune optimization quality based on media type and filename (size).

    Use Case. Larger images needs higher compression while smaller images need lower/no compression.

    Current Filter
    $quality = apply_filters( 'sgo_webp_quality', 80 );

    Current Issue: $quality is set to the same irregardless of $type. We need a way to know the $filepath in the filter for this.

    Suggested Filter
    $quality = apply_filters( 'sgo_webp_quality', 80, $filepath );

    Proposed Solution

    add_filter( 'sgo_webp_quality', 'my_sgo_webp_quality' );
    function my_sgo_webp_quality( $quality, $filepath ){
    $type = exif_imagetype( $filepath );
    $filesize = filesize( $filepath );

    switch($type){
    case: IMAGETYPE_JPEG:
    if $filesize > 100000 {
    $quality= 45;
    } else {
    $quality= 65;
    }
    break;
    default:
    }

    return $quality;
    }

    Thx!

Viewing 1 replies (of 1 total)
  • Plugin Support kuzmanstoyanov

    (@kuzmanstoyanov)

    Hello @refinedigital,

    We appreciate your suggestion. 

    I’ve already passed it to our developers and they will further check if such change would be suitable and if it could be implemented in some of the next releases of the plugin.

    Best Regards,?
    Kuzman Stoyanov

Viewing 1 replies (of 1 total)
  • The topic ‘Add $filepath to the filter sgo_webp_quality for granular control’ is closed to new replies.