apply_filters( 'image_editor_output_format', string[] $output_format, string $filename, string $mime_type )

Filters the image editor output format mapping.

Description

Enables filtering the mime type used to save images. By default, the mapping array is empty, so the mime type matches the source image.

This should be considered experimental as there are a few edge cases that still need to be solved.

When this filter is used in combination with the ‘wp_editor_set_quality’ filter, the image quality value used will be that of the original mime type, not the mapped one. This could result in unexpected image quality for generated images. See https://core.trac.wordpress.org/ticket/53667 for more details.

When a mime type is mapped to another, and two images with the same name are uploaded (image.jpg and image.webp, for example), the generated images for one will potentially overwrite the other’s. See https://core.trac.wordpress.org/ticket/53668 for more details.

See also

Parameters

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

Source

File: wp-includes/class-wp-image-editor.php

View on Trac

Changelog

Version Description
5.8.0 Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/hooks/image_editor_output_format