[wp-trac] [WordPress Trac] #15606: Remove Hardcoded Image Extensions

WordPress Trac wp-trac at lists.automattic.com
Mon Nov 29 13:56:04 UTC 2010


#15606: Remove Hardcoded Image Extensions
---------------------------+------------------------------------------------
 Reporter:  acumensystems  |       Owner:                 
     Type:  enhancement    |      Status:  new            
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  General        |     Version:                 
 Severity:  normal         |    Keywords:                 
---------------------------+------------------------------------------------

Comment(by acumensystems):

 Complementary to this, I propose a cleanup of the final, quite unreadable,
 line of logic in the function:
 {{{
 if ( 'image/' == substr($post->post_mime_type, 0, 6) || $ext && 'import'
 == $post->post_mime_type && in_array($ext, $image_exts) )
                 return true;
 }}}

 This is my proposed structuring, which I can submit a patch for as
 required:
 {{{
 // what do we know about the attachment?
 $is_imported      = 'import' == $post->post_mime_type;
 $is_mime_image    = 'image/' == substr($post->post_mime_type, 0, 6);
 $is_thumbnailable = in_array($ext, $image_exts);

 // if the mime type has this as an image, then it's an image
 if($is_mime_image)
         return true;

 // if it's an otherwise imported image, but we accept the file
 extension...
 if($is_imported && $is_thumbnailable)
         return true;
 }}}

 I do, as stated above, think the "thumbnailable" type detection does need
 to be improved/abstracted - possibly as a filter, what do you think?

 The logic of `'import' == $post->post_mime_type` seems unnecessary  - this
 is not a valid MIME type. Do we have any info on the background for when
 this would occur? Is it using Wordpress XML import/export? Or something
 different altogether?

 In my mind, if we accept the file extension, we should accept it
 regardless of MIME type.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/15606#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list