Skip to content

Instantly share code, notes, and snippets.

@ChrisHPZ
Last active August 5, 2021 14:34
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 ChrisHPZ/f1c2c3a20f7df0f9a1c8879b8dca6e38 to your computer and use it in GitHub Desktop.
Save ChrisHPZ/f1c2c3a20f7df0f9a1c8879b8dca6e38 to your computer and use it in GitHub Desktop.
Media: Introduce image_editor_output_format filter
<?php
function my_theme_setup() {
add_image_size( 'image-size-class', 1280, 720, true );
}
add_action( 'after_setup_theme', 'my_theme_setup' );
function my_theme_wp_image_editor_output_format( $formats ) {
$formats['image/jpg'] = 'image/webp';
return $formats;
}
add_filter( 'image_editor_output_format', 'my_theme_wp_image_editor_output_format' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment