_wp_image_editor_choose

The timeline below displays how wordpress function _wp_image_editor_choose has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.5

/**
 * Tests which editors are capable of supporting the request.
 *
 * @ignore
 * @since 3.5.0
 *
 * @param array $args Optional. Array of arguments for choosing a capable editor. Default empty array.
 * @return string|false Class name for the first editor that claims to support the request.
 *                      False if no editor claims to support the request.
 */
function _wp_image_editor_choose($args = array())
{
    require_once ABSPATH . WPINC . '/class-wp-image-editor.php';
    require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php';
    require_once ABSPATH . WPINC . '/class-wp-image-editor-imagick.php';
    require_once ABSPATH . WPINC . '/class-avif-info.php';
    /**
     * Filters the list of image editing library classes.
     *
     * @since 3.5.0
     *
     * @param string[] $image_editors Array of available image editor class names. Defaults are
     *                                'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'.
     */
    $implementations = apply_filters('wp_image_editors', array('WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'));
    $supports_input = false;
    foreach ($implementations as $implementation) {
        if (!call_user_func(array($implementation, 'test'), $args)) {
            continue;
        }
        // Implementation should support the passed mime type.
        if (isset($args['mime_type']) && !call_user_func(array($implementation, 'supports_mime_type'), $args['mime_type'])) {
            continue;
        }
        // Implementation should support requested methods.
        if (isset($args['methods']) && array_diff($args['methods'], get_class_methods($implementation))) {
            continue;
        }
        // Implementation should ideally support the output mime type as well if set and different than the passed type.
        if (isset($args['mime_type']) && isset($args['output_mime_type']) && $args['mime_type'] !== $args['output_mime_type'] && !call_user_func(array($implementation, 'supports_mime_type'), $args['output_mime_type'])) {
            /*
             * This implementation supports the input type but not the output type.
             * Keep looking to see if we can find an implementation that supports both.
             */
            $supports_input = $implementation;
            continue;
        }
        // Favor the implementation that supports both input and output mime types.
        return $implementation;
    }
    return $supports_input;
}

WordPress Version: 6.3

/**
 * Tests which editors are capable of supporting the request.
 *
 * @ignore
 * @since 3.5.0
 *
 * @param array $args Optional. Array of arguments for choosing a capable editor. Default empty array.
 * @return string|false Class name for the first editor that claims to support the request.
 *                      False if no editor claims to support the request.
 */
function _wp_image_editor_choose($args = array())
{
    require_once ABSPATH . WPINC . '/class-wp-image-editor.php';
    require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php';
    require_once ABSPATH . WPINC . '/class-wp-image-editor-imagick.php';
    /**
     * Filters the list of image editing library classes.
     *
     * @since 3.5.0
     *
     * @param string[] $image_editors Array of available image editor class names. Defaults are
     *                                'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'.
     */
    $implementations = apply_filters('wp_image_editors', array('WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'));
    $supports_input = false;
    foreach ($implementations as $implementation) {
        if (!call_user_func(array($implementation, 'test'), $args)) {
            continue;
        }
        // Implementation should support the passed mime type.
        if (isset($args['mime_type']) && !call_user_func(array($implementation, 'supports_mime_type'), $args['mime_type'])) {
            continue;
        }
        // Implementation should support requested methods.
        if (isset($args['methods']) && array_diff($args['methods'], get_class_methods($implementation))) {
            continue;
        }
        // Implementation should ideally support the output mime type as well if set and different than the passed type.
        if (isset($args['mime_type']) && isset($args['output_mime_type']) && $args['mime_type'] !== $args['output_mime_type'] && !call_user_func(array($implementation, 'supports_mime_type'), $args['output_mime_type'])) {
            /*
             * This implementation supports the imput type but not the output type.
             * Keep looking to see if we can find an implementation that supports both.
             */
            $supports_input = $implementation;
            continue;
        }
        // Favor the implementation that supports both input and output mime types.
        return $implementation;
    }
    return $supports_input;
}

WordPress Version: 6.1

/**
 * Tests which editors are capable of supporting the request.
 *
 * @ignore
 * @since 3.5.0
 *
 * @param array $args Optional. Array of arguments for choosing a capable editor. Default empty array.
 * @return string|false Class name for the first editor that claims to support the request.
 *                      False if no editor claims to support the request.
 */
function _wp_image_editor_choose($args = array())
{
    require_once ABSPATH . WPINC . '/class-wp-image-editor.php';
    require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php';
    require_once ABSPATH . WPINC . '/class-wp-image-editor-imagick.php';
    /**
     * Filters the list of image editing library classes.
     *
     * @since 3.5.0
     *
     * @param string[] $image_editors Array of available image editor class names. Defaults are
     *                                'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'.
     */
    $implementations = apply_filters('wp_image_editors', array('WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'));
    $supports_input = false;
    foreach ($implementations as $implementation) {
        if (!call_user_func(array($implementation, 'test'), $args)) {
            continue;
        }
        // Implementation should support the passed mime type.
        if (isset($args['mime_type']) && !call_user_func(array($implementation, 'supports_mime_type'), $args['mime_type'])) {
            continue;
        }
        // Implementation should support requested methods.
        if (isset($args['methods']) && array_diff($args['methods'], get_class_methods($implementation))) {
            continue;
        }
        // Implementation should ideally support the output mime type as well if set and different than the passed type.
        if (isset($args['mime_type']) && isset($args['output_mime_type']) && $args['mime_type'] !== $args['output_mime_type'] && !call_user_func(array($implementation, 'supports_mime_type'), $args['output_mime_type'])) {
            // This implementation supports the imput type but not the output type.
            // Keep looking to see if we can find an implementation that supports both.
            $supports_input = $implementation;
            continue;
        }
        // Favor the implementation that supports both input and output mime types.
        return $implementation;
    }
    return $supports_input;
}

WordPress Version: 5.7

/**
 * Tests which editors are capable of supporting the request.
 *
 * @ignore
 * @since 3.5.0
 *
 * @param array $args Optional. Array of arguments for choosing a capable editor. Default empty array.
 * @return string|false Class name for the first editor that claims to support the request.
 *                      False if no editor claims to support the request.
 */
function _wp_image_editor_choose($args = array())
{
    require_once ABSPATH . WPINC . '/class-wp-image-editor.php';
    require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php';
    require_once ABSPATH . WPINC . '/class-wp-image-editor-imagick.php';
    /**
     * Filters the list of image editing library classes.
     *
     * @since 3.5.0
     *
     * @param string[] $image_editors Array of available image editor class names. Defaults are
     *                                'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'.
     */
    $implementations = apply_filters('wp_image_editors', array('WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'));
    foreach ($implementations as $implementation) {
        if (!call_user_func(array($implementation, 'test'), $args)) {
            continue;
        }
        if (isset($args['mime_type']) && !call_user_func(array($implementation, 'supports_mime_type'), $args['mime_type'])) {
            continue;
        }
        if (isset($args['methods']) && array_diff($args['methods'], get_class_methods($implementation))) {
            continue;
        }
        return $implementation;
    }
    return false;
}

WordPress Version: 5.4

/**
 * Tests which editors are capable of supporting the request.
 *
 * @ignore
 * @since 3.5.0
 *
 * @param array $args Optional. Array of arguments for choosing a capable editor. Default empty array.
 * @return string|false Class name for the first editor that claims to support the request. False if no
 *                     editor claims to support the request.
 */
function _wp_image_editor_choose($args = array())
{
    require_once ABSPATH . WPINC . '/class-wp-image-editor.php';
    require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php';
    require_once ABSPATH . WPINC . '/class-wp-image-editor-imagick.php';
    /**
     * Filters the list of image editing library classes.
     *
     * @since 3.5.0
     *
     * @param string[] $image_editors Array of available image editor class names. Defaults are
     *                                'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'.
     */
    $implementations = apply_filters('wp_image_editors', array('WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'));
    foreach ($implementations as $implementation) {
        if (!call_user_func(array($implementation, 'test'), $args)) {
            continue;
        }
        if (isset($args['mime_type']) && !call_user_func(array($implementation, 'supports_mime_type'), $args['mime_type'])) {
            continue;
        }
        if (isset($args['methods']) && array_diff($args['methods'], get_class_methods($implementation))) {
            continue;
        }
        return $implementation;
    }
    return false;
}

WordPress Version: 4.6

/**
 * Tests which editors are capable of supporting the request.
 *
 * @ignore
 * @since 3.5.0
 *
 * @param array $args Optional. Array of arguments for choosing a capable editor. Default empty array.
 * @return string|false Class name for the first editor that claims to support the request. False if no
 *                     editor claims to support the request.
 */
function _wp_image_editor_choose($args = array())
{
    require_once ABSPATH . WPINC . '/class-wp-image-editor.php';
    require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php';
    require_once ABSPATH . WPINC . '/class-wp-image-editor-imagick.php';
    /**
     * Filters the list of image editing library classes.
     *
     * @since 3.5.0
     *
     * @param array $image_editors List of available image editors. Defaults are
     *                             'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'.
     */
    $implementations = apply_filters('wp_image_editors', array('WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'));
    foreach ($implementations as $implementation) {
        if (!call_user_func(array($implementation, 'test'), $args)) {
            continue;
        }
        if (isset($args['mime_type']) && !call_user_func(array($implementation, 'supports_mime_type'), $args['mime_type'])) {
            continue;
        }
        if (isset($args['methods']) && array_diff($args['methods'], get_class_methods($implementation))) {
            continue;
        }
        return $implementation;
    }
    return false;
}

WordPress Version: 4.3

/**
 * Tests which editors are capable of supporting the request.
 *
 * @ignore
 * @since 3.5.0
 *
 * @param array $args Optional. Array of arguments for choosing a capable editor. Default empty array.
 * @return string|false Class name for the first editor that claims to support the request. False if no
 *                     editor claims to support the request.
 */
function _wp_image_editor_choose($args = array())
{
    require_once ABSPATH . WPINC . '/class-wp-image-editor.php';
    require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php';
    require_once ABSPATH . WPINC . '/class-wp-image-editor-imagick.php';
    /**
     * Filter the list of image editing library classes.
     *
     * @since 3.5.0
     *
     * @param array $image_editors List of available image editors. Defaults are
     *                             'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'.
     */
    $implementations = apply_filters('wp_image_editors', array('WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'));
    foreach ($implementations as $implementation) {
        if (!call_user_func(array($implementation, 'test'), $args)) {
            continue;
        }
        if (isset($args['mime_type']) && !call_user_func(array($implementation, 'supports_mime_type'), $args['mime_type'])) {
            continue;
        }
        if (isset($args['methods']) && array_diff($args['methods'], get_class_methods($implementation))) {
            continue;
        }
        return $implementation;
    }
    return false;
}

WordPress Version: 4.2

/**
 * Tests which editors are capable of supporting the request.
 *
 * @ignore
 * @since 3.5.0
 *
 * @param array $args Optional. Array of arguments for choosing a capable editor. Default empty array.
 * @return string|bool Class name for the first editor that claims to support the request. False if no
 *                     editor claims to support the request.
 */
function _wp_image_editor_choose($args = array())
{
    require_once ABSPATH . WPINC . '/class-wp-image-editor.php';
    require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php';
    require_once ABSPATH . WPINC . '/class-wp-image-editor-imagick.php';
    /**
     * Filter the list of image editing library classes.
     *
     * @since 3.5.0
     *
     * @param array $image_editors List of available image editors. Defaults are
     *                             'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'.
     */
    $implementations = apply_filters('wp_image_editors', array('WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'));
    foreach ($implementations as $implementation) {
        if (!call_user_func(array($implementation, 'test'), $args)) {
            continue;
        }
        if (isset($args['mime_type']) && !call_user_func(array($implementation, 'supports_mime_type'), $args['mime_type'])) {
            continue;
        }
        if (isset($args['methods']) && array_diff($args['methods'], get_class_methods($implementation))) {
            continue;
        }
        return $implementation;
    }
    return false;
}

WordPress Version: 3.9

/**
 * Tests which editors are capable of supporting the request.
 *
 * @since 3.5.0
 * @access private
 *
 * @param array $args Additional data. Accepts { 'mime_type'=>string, 'methods'=>{string, string, ...} }
 * @return string|bool Class name for the first editor that claims to support the request. False if no editor claims to support the request.
 */
function _wp_image_editor_choose($args = array())
{
    require_once ABSPATH . WPINC . '/class-wp-image-editor.php';
    require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php';
    require_once ABSPATH . WPINC . '/class-wp-image-editor-imagick.php';
    /**
     * Filter the list of image editing library classes.
     *
     * @since 3.5.0
     *
     * @param array $image_editors List of available image editors. Defaults are
     *                             'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'.
     */
    $implementations = apply_filters('wp_image_editors', array('WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'));
    foreach ($implementations as $implementation) {
        if (!call_user_func(array($implementation, 'test'), $args)) {
            continue;
        }
        if (isset($args['mime_type']) && !call_user_func(array($implementation, 'supports_mime_type'), $args['mime_type'])) {
            continue;
        }
        if (isset($args['methods']) && array_diff($args['methods'], get_class_methods($implementation))) {
            continue;
        }
        return $implementation;
    }
    return false;
}

WordPress Version: 3.7

/**
 * Tests which editors are capable of supporting the request.
 *
 * @since 3.5.0
 * @access private
 *
 * @param array $args Additional data. Accepts { 'mime_type'=>string, 'methods'=>{string, string, ...} }
 * @return string|bool Class name for the first editor that claims to support the request. False if no editor claims to support the request.
 */
function _wp_image_editor_choose($args = array())
{
    require_once ABSPATH . WPINC . '/class-wp-image-editor.php';
    require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php';
    require_once ABSPATH . WPINC . '/class-wp-image-editor-imagick.php';
    $implementations = apply_filters('wp_image_editors', array('WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'));
    foreach ($implementations as $implementation) {
        if (!call_user_func(array($implementation, 'test'), $args)) {
            continue;
        }
        if (isset($args['mime_type']) && !call_user_func(array($implementation, 'supports_mime_type'), $args['mime_type'])) {
            continue;
        }
        if (isset($args['methods']) && array_diff($args['methods'], get_class_methods($implementation))) {
            continue;
        }
        return $implementation;
    }
    return false;
}