image_editor_output_format хук-фильтрWP 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.

Использование

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.

По умолчанию: empty array

  • ...$0(строка)
    The new mime type.
$filename(строка)
Path to the image.
$mime_type(строка)
The source image mime type.

Список изменений

С версии 5.8.0 Введена.

Где вызывается хук

WP_Image_Editor::get_output_format()
image_editor_output_format
wp_unique_filename()
image_editor_output_format
wp_get_image_editor()
image_editor_output_format
wp-includes/class-wp-image-editor.php 378
$output_format = apply_filters( 'image_editor_output_format', array(), $filename, $mime_type );
wp-includes/functions.php 2683
$output_formats = apply_filters( 'image_editor_output_format', array(), $_dir . $filename, $mime_type );
wp-includes/media.php 3861
$output_format = apply_filters( 'image_editor_output_format', array(), $path, $args['mime_type'] );

Где используется хук в WordPress

Использование не найдено.