• Is there a way convert all image file to webp even if the webp file is larger than original file?

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

    (@jamesosborne)

    Great question @weblazer. While I’m not aware of any option to do so at present, I did create a feature request on the plugins GitHub repository proposing a filter or an option on going so. You can subscribe to, or chime in on the below:
    https://github.com/WordPress/performance/issues/1510

    Note that there may be the possibility to undo the check for the file size output that determines whether a WebP version is generated. Hopefully there will be an update provided in that GitHub issue.

    It may also be possible to lower the quality of the WebP image, which would result in fewer JPEG images not having a WebP version generated (as the generated WebP image is more likely to be smaller in file size). An example of the quality changed from the default 82 to 40 can be found below:

    function set_webp_quality( $quality, $mime_type ) {
    if ( 'image/webp' === $mime_type ) {
    return 40;
    }
    return $quality;
    }
    add_filter( 'wp_editor_set_quality', 'set_webp_quality', 10, 2 );

    Let me know if you have any questions with the above.

    Plugin Support James Osborne

    (@jamesosborne)

    Just to let you know that there is already a filter you can use to ensure WebP images are always generated. See below:
    add_filter( 'webp_uploads_discard_larger_generated_images', '__return_false' );

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