Make WordPress Core

Ticket #39552: functions.php.2.patch

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

Fixed comment, amended variable name for more precise information about its content

  • wp-includes/functions.php

     
    23662366         */
    23672367        try {
    23682368                if ( is_callable( 'exif_imagetype' ) ) {
    2369                         $mime = image_type_to_mime_type( exif_imagetype( $file ) );
     2369                        $imagetype = exif_imagetype( $file );
     2370                        // avoid falling back to application/octet-stream when exif_imagetype returns false
     2371                        if( $imagetype !== false ) {
     2372                                $mime = image_type_to_mime_type( $imagetype );
     2373                        } else {
     2374                                $mime = false;
     2375                        }
    23702376                } elseif ( function_exists( 'getimagesize' ) ) {
    23712377                        $imagesize = getimagesize( $file );
    23722378                        $mime = ( isset( $imagesize['mime'] ) ) ? $imagesize['mime'] : false;
     
    23732379                } else {
    23742380                        $mime = false;
    23752381                }
     2382                 if( $mime === false && function_exists ( 'finfo_file' ) ){
     2383                        /* if the mime type is false we might have an image file not supported by PHP Constants (this applies
     2384                         * at least to svg, but  might apply to other file types) To fix this, use finfo to determine the mimetype * instead
     2385                         */
     2386                        $finfo = finfo_open( FILEINFO_MIME_TYPE );
     2387                        $mime = finfo_file( $finfo, $file );
     2388                        finfo_close( $finfo );
     2389                }
    23762390        } catch ( Exception $e ) {
    23772391                $mime = false;
    23782392        }