Skip to content

Instantly share code, notes, and snippets.

@adamsilverstein
Last active September 30, 2022 19:59
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/89c2d0c2128422c93e4fa6d8d0489be0 to your computer and use it in GitHub Desktop.
Save adamsilverstein/89c2d0c2128422c93e4fa6d8d0489be0 to your computer and use it in GitHub Desktop.
Output WebP mini plugin
<?php
/**
* Outout WebP sub size images.
*
* @wordpress-plugin
* Plugin Name: WebP-only.
* Description: Output 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_image_editor_output_format( $mappings ){
$mappings[ 'image/jpeg' ] = 'image/webp';
return $mappings;
}
add_filter( 'image_editor_output_format', 'filter_image_editor_output_format' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment