image_editor_output_format
Filters the image editor output format mapping.
Enables filtering the mime type used to save images. By default, the mapping array is empty, so the mime type matches the source image.
Usage
add_filter( 'image_editor_output_format', 'wp_kama_image_editor_output_format_filter', 10, 3 ); /** * Function for `image_editor_output_format` filter-hook. * * @param string[] $output_format An array of mime type mappings. Maps a source mime type to a new destination mime type. * @param string $filename Path to the image. * @param string $mime_type The source image mime type. * * @return string[] */ function wp_kama_image_editor_output_format_filter( $output_format, $filename, $mime_type ){ // filter... return $output_format; }
- $output_format(string[])
An array of mime type mappings. Maps a source mime type to a new destination mime type.
Default: empty array
- ...$0(string)
The new mime type.
- ...$0(string)
- $filename(string)
- Path to the image.
- $mime_type(string)
- The source image mime type.
Changelog
Since 5.8.0 | Introduced. |
Where the hook is called
image_editor_output_format
image_editor_output_format
wp-includes/class-wp-image-editor.php 388
$output_format = apply_filters( 'image_editor_output_format', array(), $filename, $mime_type );
wp-includes/functions.php 2710
$output_formats = apply_filters( 'image_editor_output_format', array(), $_dir . $filename, $mime_type );
wp-includes/media.php 4064
$output_format = apply_filters( 'image_editor_output_format', array(), $path, $args['mime_type'] );