Make WordPress Core

Ticket #39552: functions.php.patch

File functions.php.patch, 1.2 KB (added by freakpants, 8 years ago)

Amended version of the patch that should not impact application/octet-stream images.

  • wp-includes/functions.php

     
    23662366         */
    23672367        try {
    23682368                if ( is_callable( 'exif_imagetype' ) ) {
    2369                         $mime = image_type_to_mime_type( exif_imagetype( $file ) );
     2369                        $mime = exif_imagetype( $file );
     2370                        // avoid falling back to application/octet-stream when exif_imagetype returns false
     2371                        if( $mime !== false ) {
     2372                                $mime = image_type_to_mime_type( $mime );
     2373                        }
    23702374                } elseif ( function_exists( 'getimagesize' ) ) {
    23712375                        $imagesize = getimagesize( $file );
    23722376                        $mime = ( isset( $imagesize['mime'] ) ) ? $imagesize['mime'] : false;
     
    23732377                } else {
    23742378                        $mime = false;
    23752379                }
     2380                 if( $mime === false && function_exists ( 'finfo_file' ) ){
     2381                        /* if the mime type is false image file not supported by PHP Constants (this applies at least to
     2382                         * svg, but  might apply to other file types) To fix this, use finfo to determine the mimetype instead
     2383                         */
     2384                        $finfo = finfo_open( FILEINFO_MIME_TYPE );
     2385                        $mime = finfo_file( $finfo, $file );
     2386                        finfo_close( $finfo );
     2387                }
    23762388        } catch ( Exception $e ) {
    23772389                $mime = false;
    23782390        }