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 HEIC/HEIF images are converted to JPEGs.

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. By default maps HEIC/HEIF input to JPEG output.
 * @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. By default maps HEIC/HEIF input to JPEG output.

  • ...$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.
Since 6.7.0 The default was changed from an empty array to an array containing the HEIC/HEIF images mime types.

Where the hook is called

wp_get_image_editor_output_format()
image_editor_output_format
wp-includes/media.php 6346
return apply_filters( 'image_editor_output_format', $output_format, $filename, $mime_type );

Where the hook is used in WordPress

Usage not found.