• While uploading woocommerce images we already compress files at our on photoshop, but when they are uploaded and converted to webp format by your plugin the images are compressed more than what we expect. Is there any setting where compression level can be adujusted?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support James Osborne

    (@jamesosborne)

    Thanks for reaching out @mananmushtaq02. Images will only be generated in modern image formats if the output image is lower in file size than the one uploaded.

    Is there any setting where compression level can be adujusted?

    You can use wp_editor_set_quality to change the modern image format quality. Below is an example:


    function filter_img_quality( $quality, $mime_type ) {
    if ( 'image/avif' === $mime_type ) {
    return 55;
    }
    return $quality;
    }
    add_filter( 'wp_editor_set_quality', 'filter_img_quality', 10, 2 );

    Hopefully the above is of use. Let me know if you have any questions with the above.

    Thread Starter mananmushtaq02

    (@mananmushtaq02)

    In below code I changed $quality = 86; to $quality = 16; and $quality = 96; aswell. But nothing changed in compression quality when I uploaded an image again.

    Is there something else to be done

    /**
    * Returns the default compression quality setting for the mime type.
    *
    * @since 5.8.1
    *
    * @param string $mime_type
    * @return int The default quality setting for the mime type.
    */
    protected function get_default_quality( $mime_type ) {
    switch ( $mime_type ) {
    case ‘image/webp’:
    $quality = 86;
    break;
    case ‘image/jpeg’:
    default:
    $quality = $this->default_quality;
    }

    Plugin Support James Osborne

    (@jamesosborne)

    Is it possible that the image you’re trying to upload is already very low in file size? Feel free to share a link for me to check with if you wish.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.