WordPress.org

Make WordPress Core

Changeset 22864


Ignore:
Timestamp:
11/27/2012 02:52:24 PM (6 years ago)
Author:
ryan
Message:

Clean up WP_Image_Editor_Imagick::test(). Props DH-Shredder. see #22543

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-wp-image-editor-imagick.php

    r22849 r22864  
    3939     */
    4040    public static function test( $args = array() ) {
     41
     42        // First, test Imagick's extension and classes.
     43        if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick' ) || ! class_exists( 'ImagickPixel' ) )
     44            return false;
    4145
    4246        $required_methods = array(
     
    6064        );
    6165
    62         // Check for requirements
    63         if ( ! extension_loaded( 'imagick' ) ||
    64              ! class_exists( 'Imagick' ) ||
    65              ! is_callable( 'Imagick', 'queryFormats' ) ||
    66              ! class_exists( 'ImagickPixel' ) ||
     66        // Now, test for deep requirements within Imagick.
     67        if ( ! is_callable( 'Imagick', 'queryFormats' ) ||
    6768             ! defined( 'imagick::COMPRESSION_JPEG' ) ||
    6869             array_diff( $required_methods, get_class_methods( 'Imagick' ) ) ) {
     
    7172        }
    7273
    73         /**
    74          * setIteratorIndex is optional unless mime is an animated format.
    75          * Here, we just say no if a user is attempting to
    76          * edit a GIF and setIteratorIndex isn't available.
    77          */
    78         if ( ( ! isset( $args['mime_type'] ) || $args['mime_type'] == 'image/gif' ) &&
    79              ! method_exists( 'Imagick', 'setIteratorIndex' ) ) {
    80 
    81             return false;
    82         }
    83 
    8474        return true;
    8575    }
     
    9989        if ( ! $imagick_extension )
    10090            return false;
     91
     92        // setIteratorIndex is optional unless mime is an animated format.
     93        // Here, we just say no if you are missing it and aren't loading a jpeg.
     94        if ( ! method_exists( 'Imagick', 'setIteratorIndex' ) && $mime_type != 'image/jpeg' )
     95                return false;
    10196
    10297        try {
Note: See TracChangeset for help on using the changeset viewer.