Last active
March 18, 2022 14:14
-
-
Save adamsilverstein/7b9a294f6bdb58a2bcd0d5ee47ec3860 to your computer and use it in GitHub Desktop.
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 | |
| /** | |
| * Multiple mime types for WordPress. | |
| * | |
| * @wordpress-plugin | |
| * Plugin Name: Multi-mime. | |
| * Description: Uploaded images in multiple mime types, requires https://github.com/WordPress/wordpress-develop/pull/2239. | |
| * 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 | |
| */ | |
| /** | |
| * Add additional mime type meta data when generating image sub sizes. | |
| */ | |
| function filter_image_editor_output_formats( $mime_types ){ | |
| if ( isset( $mime_types['image/jpeg'] ) && ! isset( $mime_types['image/jpeg']['image/webp'] ) ) { | |
| array_push( $mime_types['image/jpeg'], 'image/webp' ); | |
| } | |
| return $mime_types; | |
| } | |
| add_filter( 'image_editor_output_formats', 'filter_image_editor_output_formats' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment