Make WordPress Core


Ignore:
Timestamp:
11/22/2012 09:52:16 AM (14 years ago)
Author:
nacin
Message:

WP_Image_Editor: the last stand.

  • Have wp_get_image_editor() rather than WP_Image_Editor::get_instance(). Having static factory methods would be less confusing if there weren't also static methods tied to individual editor implementations.
  • Lazy-load the WP_Image_Editor base class and editor implementations.
  • Have WP_Image_Editor_GD::supports_mime_type() actually check which types it supports.
  • Deprecate gd_edit_image_support() in favor of wp_image_editor_supports().

props DH-Shredder, scribu, markoheijnen. fixes #22356. see #6821.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/deprecated.php

    r22463 r22817  
    32113211 * @since 2.1.0
    32123212 * @deprecated 3.5.0
    3213  * @see WP_Image_Editor
     3213 * @see wp_get_image_editor()
    32143214 *
    32153215 * @param string $file Filename of the image to load.
    … …  
    32173217 */
    32183218function wp_load_image( $file ) {
    3219         _deprecated_function( __FUNCTION__, '3.5', 'WP_Image_Editor' );
     3219        _deprecated_function( __FUNCTION__, '3.5', 'wp_get_image_editor()' );
    32203220
    32213221        if ( is_numeric( $file ) )
    … …  
    32513251 * @since 2.5.0
    32523252 * @deprecated 3.5.0
    3253  * @see WP_Image_Editor
     3253 * @see wp_get_image_editor()
    32543254 *
    32553255 * @param string $file Image file path.
    … …  
    32633263 */
    32643264function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) {
    3265         _deprecated_function( __FUNCTION__, '3.5', 'WP_Image_Editor' );
    3266 
    3267         $editor = WP_Image_Editor::get_instance( $file );
     3265        _deprecated_function( __FUNCTION__, '3.5', 'wp_get_image_editor()' );
     3266
     3267        $editor = wp_get_image_editor( $file );
    32683268        if ( is_wp_error( $editor ) )
    32693269                return $editor;
    … …  
    33303330 */
    33313331function _save_post_hook() {}
     3332
     3333/**
     3334 * Check if the installed version of GD supports particular image type
     3335 *
     3336 * @since 2.9.0
     3337 * @deprecated 3.5.0
     3338 * see wp_image_editor_supports()
     3339 *
     3340 * @param string $mime_type
     3341 * @return bool
     3342 */
     3343function gd_edit_image_support($mime_type) {
     3344        _deprecated_function( __FUNCTION__, '3.5', 'wp_image_editor_supports()' );
     3345
     3346        if ( function_exists('imagetypes') ) {
     3347                switch( $mime_type ) {
     3348                        case 'image/jpeg':
     3349                                return (imagetypes() & IMG_JPG) != 0;
     3350                        case 'image/png':
     3351                                return (imagetypes() & IMG_PNG) != 0;
     3352                        case 'image/gif':
     3353                                return (imagetypes() & IMG_GIF) != 0;
     3354                }
     3355        } else {
     3356                switch( $mime_type ) {
     3357                        case 'image/jpeg':
     3358                                return function_exists('imagecreatefromjpeg');
     3359                        case 'image/png':
     3360                                return function_exists('imagecreatefrompng');
     3361                        case 'image/gif':
     3362                                return function_exists('imagecreatefromgif');
     3363                }
     3364        }
     3365        return false;
     3366}
Note: See TracChangeset for help on using the changeset viewer.