WordPress.org

Make WordPress Core

Ticket #28077: file_is_displayable_image.diff

File file_is_displayable_image.diff, 812 bytes (added by joehoyle, 6 years ago)
  • wp-admin/includes/image.php

    diff --git wp-admin/includes/image.php wp-admin/includes/image.php
    index 07c4f8e..1aa072e 100644
    function file_is_valid_image($path) { 
    372372 * @return bool True if suitable, false if not suitable.
    373373 */
    374374function file_is_displayable_image($path) {
    375         $info = @getimagesize($path);
    376         if ( empty($info) )
     375        $image_type = @exif_imagetype( $path );
     376        if ( empty($image_type) )
    377377                $result = false;
    378         elseif ( !in_array($info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)) )     // only gif, jpeg and png images can reliably be displayed
     378        elseif ( !in_array($image_type, array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)) )  // only gif, jpeg and png images can reliably be displayed
    379379                $result = false;
    380380        else
    381381                $result = true;