WordPress.org

Make WordPress Core

Ticket #3411: 3411b.diff

File 3411b.diff, 1.2 KB (added by mdawaffe, 8 years ago)

Fix wp_attachment_is_image() extension checks

  • wp-includes/post-template.php

     
    349349 
    350350        $file = get_attached_file( $post->ID ); 
    351351 
    352         $exts = array('jpg', 'gif', 'png'); 
    353  
    354352        if ( !$fullsize && $thumbfile = wp_get_attachment_thumb_file( $post->ID ) ) { 
    355353                // We have a thumbnail desired, specified and existing 
    356354 
  • wp-includes/post.php

     
    14711471        if ( !$file = get_attached_file( $post->ID ) ) 
    14721472                return false; 
    14731473 
    1474         $image_exts = array('/jpg', 'jpeg', '/gif', '/png'); 
     1474        $ext = preg_match('/\.([^.]+)$/', $file, $matches) ? strtolower($matches[1]) : false; 
    14751475 
    1476         if ( 'image/' == substr($post->post_mime_type, 0, 6) || 'import' == $post->post_mime_type && in_array(substr($file, -4), $exts) ) 
     1476        $image_exts = array('jpg', 'jpeg', 'gif', 'png'); 
     1477 
     1478        if ( 'image/' == substr($post->post_mime_type, 0, 6) || $ext && 'import' == $post->post_mime_type && in_array($ext, $image_exts) ) 
    14771479                return true; 
    14781480        return false; 
    14791481}