image_editor_output_format filter-hookWP 5.8.0

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.
$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

WP_Image_Editor::get_output_format()
image_editor_output_format
wp_unique_filename()
image_editor_output_format
wp-includes/class-wp-image-editor.php 367
$output_format = apply_filters( 'image_editor_output_format', array(), $filename, $mime_type );
wp-includes/functions.php 2685
$output_formats = apply_filters( 'image_editor_output_format', array(), $_dir . $filename, $mime_type );

Where the hook is used in WordPress

Usage not found.