[wp-trac] [WordPress Trac] #20205: move image_downsize filter to beginning of image_downsize() function

WordPress Trac wp-trac at lists.automattic.com
Fri Mar 9 02:20:22 UTC 2012


#20205: move image_downsize filter to beginning of image_downsize() function
----------------------------+------------------------------
 Reporter:  helgatheviking  |       Owner:
     Type:  enhancement     |      Status:  new
 Priority:  normal          |   Milestone:  Awaiting Review
Component:  Media           |     Version:  3.4
 Severity:  normal          |  Resolution:
 Keywords:                  |
----------------------------+------------------------------

Comment (by helgatheviking):

 i looked at the wp_mime_type_icon filter and it almost works.  you can
 send back a custom URL to the wp_mime_type_icon filter, but the URL gets
 truncated down to simply the filename by wp_basename($src) in the
 wp_get_attachment_image_src() function.


 {{{
 if ( $icon && $src = wp_mime_type_icon($attachment_id) ) {
                 $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC .
 '/images/crystal' );
                 $src_file = $icon_dir . '/' . wp_basename($src);
                 @list($width, $height) = getimagesize($src_file);
         }
 }}}
 i've also tried filtering the icon directory through the icon_dir filter,
 but b/c there are no variables passed i cannot get the directory to be the
 exact directory the custom icon is in.

 so i can filter the $src of my icon to be:



 http://localhost/multi/wp-content/uploads/2011/11/capri-100x100.jpg


 and i can filter the icon directory path to be the uploads directory

 D:\Users\helga\xampp\htdocs\multi/wp-content/uploads

 but b/c the
 {{{
 $src_file = $icon_dir . '/' . wp_basename($src);
 }}}


 the end result for $src_file is:

 D:\Users\helga\xampp\htdocs\multi/wp-content/uploads/capri-100x100.jpg

 which is missing the sub-directories.  i thought about trying to send an
 empty path to the icon_dir filter and sending the full path to the
 wp_mime_type_filter, but you can't do that either b/c of that string '/'
 in the way.






 http://localhost/multi/wp-content/uploads/2011/11/capri-100x100.jpg

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


More information about the wp-trac mailing list