Last active
December 2, 2022 19:47
-
-
Save adamsilverstein/388df303f3cd90b7bfb113989536995d to your computer and use it in GitHub Desktop.
only webp with performance plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Output only WebP sub size images. | |
* | |
* @wordpress-plugin | |
* Plugin Name: WebP-only. | |
* Description: Output only WebP sub size images. | |
* Plugin URI: | |
* Version: 1.0.0 | |
* Author: Adam Silverstein, Google | |
* License: Apache License 2.0 | |
* License URI: https://www.apache.org/licenses/LICENSE-2.0 | |
*/ | |
function filter_webp_uploads_upload_image_mime_transforms( $mime_types ){ | |
$mime_types[ 'image/jpeg' ] = array( 'image/webp' ); // only output WebP for uploaded jpegs. | |
return $mime_types; | |
} | |
add_filter( 'webp_uploads_upload_image_mime_transforms', 'filter_webp_uploads_upload_image_mime_transforms' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment