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 array $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 array
 */
function wp_kama_image_editor_output_format_filter( $output_format, $filename, $mime_type ){

	// filter...
	return $output_format;
}
$output_format(array<string, 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.
$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_REST_Attachments_Controller::prepare_item_for_response()
image_editor_output_format
wp-includes/media.php 6567
return apply_filters( 'image_editor_output_format', $output_format, $filename, $mime_type );
wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php 1587-1592
$output_formats = apply_filters(
	'image_editor_output_format',
	array( $mime_type => $mime_type ),
	$filename ? $filename : '',
	$mime_type
);
wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php 1611-1616
$output_formats = apply_filters(
	'image_editor_output_format',
	array( $mime_type => $mime_type ),
	$filename ? $filename : '',
	$mime_type
);

Where the hook is used in WordPress

wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php 2794
add_filter( 'image_editor_output_format', '__return_empty_array', 100 );
wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php 2840
remove_filter( 'image_editor_output_format', '__return_empty_array', 100 );
wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php 534
add_filter( 'image_editor_output_format', '__return_empty_array', 100 );
wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php 803
remove_filter( 'image_editor_output_format', '__return_empty_array', 100 );