Make WordPress Core

Ticket #49889: 49889.diff

File 49889.diff, 3.2 KB (added by Howdy_McGee, 5 years ago)

WP_DEBUG Wrapped

  • image.php

     
    9393        // Use the originally uploaded image dimensions as full_width and full_height.
    9494        if ( ! empty( $image_meta['original_image'] ) ) {
    9595                $image_file = wp_get_original_image_path( $attachment_id );
    96                 $imagesize  = @getimagesize( $image_file );
     96               
     97                if( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     98                        $imagesize = getimagesize( $image_file );
     99                } else {
     100                        $imagesize = @getimagesize( $image_file );
     101                }
     102               
    97103        }
    98104
    99105        if ( ! empty( $imagesize ) ) {
     
    224230 * @return array The image attachment meta data.
    225231 */
    226232function wp_create_image_subsizes( $file, $attachment_id ) {
    227         $imagesize = @getimagesize( $file );
     233       
     234        if( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     235                $imagesize = getimagesize( $file );
     236        } else {
     237                $imagesize = @getimagesize( $file );
     238        }
    228239
    229240        if ( empty( $imagesize ) ) {
    230241                // File is not an image.
     
    687698                return false;
    688699        }
    689700
    690         list( , , $image_type ) = @getimagesize( $file );
     701        if( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     702                list( , , $image_type ) = getimagesize( $file );
     703        } else {
     704                list( , , $image_type ) = @getimagesize( $file );
     705        }
    691706
    692707        /*
    693708         * EXIF contains a bunch of data we'll probably never need formatted in ways
     
    716731         * as caption, description etc.
    717732         */
    718733        if ( is_callable( 'iptcparse' ) ) {
    719                 @getimagesize( $file, $info );
     734               
     735                if( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     736                        getimagesize( $file, $info );
     737                } else {
     738                        @getimagesize( $file, $info );
     739                }
    720740
    721741                if ( ! empty( $info['APP13'] ) ) {
    722                         $iptc = @iptcparse( $info['APP13'] );
     742                       
     743                        if( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     744                                $iptc = iptcparse( $info['APP13'] );
     745                        } else {
     746                                $iptc = @iptcparse( $info['APP13'] );
     747                        }
    723748
    724749                        // Headline, "A brief synopsis of the caption".
    725750                        if ( ! empty( $iptc['2#105'][0] ) ) {
     
    779804        $exif_image_types = apply_filters( 'wp_read_image_metadata_types', array( IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM ) );
    780805
    781806        if ( is_callable( 'exif_read_data' ) && in_array( $image_type, $exif_image_types, true ) ) {
    782                 $exif = @exif_read_data( $file );
     807               
     808                if( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     809                        $exif = exif_read_data( $file );
     810                } else {
     811                        $exif = @exif_read_data( $file );
     812                }
    783813
    784814                if ( ! empty( $exif['ImageDescription'] ) ) {
    785815                        mbstring_binary_safe_encoding();
     
    877907 * @return bool True if valid image, false if not valid image.
    878908 */
    879909function file_is_valid_image( $path ) {
    880         $size = @getimagesize( $path );
     910       
     911        if( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     912                $size = getimagesize( $path );
     913        } else {
     914                $size = @getimagesize( $path );
     915        }
     916       
    881917        return ! empty( $size );
    882918}
    883919
     
    892928function file_is_displayable_image( $path ) {
    893929        $displayable_image_types = array( IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_ICO );
    894930
    895         $info = @getimagesize( $path );
     931        if( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
     932                $info = getimagesize( $path );
     933        } else {
     934                $info = @getimagesize( $path );
     935        }
     936       
    896937        if ( empty( $info ) ) {
    897938                $result = false;
    898939        } elseif ( ! in_array( $info[2], $displayable_image_types, true ) ) {