Skip to content

Instantly share code, notes, and snippets.

@adamsilverstein
Last active December 2, 2022 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamsilverstein/388df303f3cd90b7bfb113989536995d to your computer and use it in GitHub Desktop.
Save adamsilverstein/388df303f3cd90b7bfb113989536995d to your computer and use it in GitHub Desktop.
only webp with performance plugin
<?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