Last active
June 5, 2024 15:49
-
-
Save adamsilverstein/35e9d9fcdb1933e67ce38a7ccb119f3d to your computer and use it in GitHub Desktop.
Output WebP images from PNG uploads
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 | |
/** | |
* Outout WebP sub size images from PNG uploads. | |
* | |
* @wordpress-plugin | |
* Plugin Name: WebP-from-PNG. | |
* Description: Output WebP sub size images for PNG uploads. | |
* 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/png' ] = '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