Filter hook 'image_editor_output_format'

in WP Core File wp-includes/media.php at line 6352

View Source

image_editor_output_format

Filter Hook
Description
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. containing the HEIC/HEIF images mime types. }

Hook Information

File Location wp-includes/media.php View on GitHub
Hook Type Filter
Line Number 6352

Hook Parameters

Type Name Description
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.
string $filename Path to the image.
string $mime_type The source image mime type.

Usage Examples

Basic Usage
<?php
// Hook into image_editor_output_format
add_filter('image_editor_output_format', 'my_custom_filter', 10, 3);

function my_custom_filter($output_format, $filename, $mime_type) {
    // Your custom filtering logic here
    return $output_format;
}

Source Code Context

wp-includes/media.php:6352 - How this hook is used in WordPress core
<?php
6347  	 *     @type string ...$0 The new mime type.
6348  	 * }
6349  	 * @param string $filename  Path to the image.
6350  	 * @param string $mime_type The source image mime type.
6351  	 */
6352  	return apply_filters( 'image_editor_output_format', $output_format, $filename, $mime_type );
6353  }

PHP Documentation

<?php
/**
	 * 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.
	 *
	 * @see WP_Image_Editor::get_output_format()
	 *
	 * @since 5.8.0
	 * @since 6.7.0 The default was changed from an empty array to an array
	 *              containing the HEIC/HEIF images mime types.
	 *
	 * @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.
	 *
	 *     @type string ...$0 The new mime type.
	 * }
	 * @param string $filename  Path to the image.
	 * @param string $mime_type The source image mime type.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 3
  • File: wp-includes/media.php
Related Hooks

Related hooks will be displayed here in future updates.