[wp-trac] [WordPress Trac] #32117: wp_get_attachment_metadata sizes array file misses path if using year/month organizing

WordPress Trac noreply at wordpress.org
Fri Oct 9 10:30:59 UTC 2015


#32117: wp_get_attachment_metadata sizes array file misses path if using year/month
organizing
--------------------------+------------------------------
 Reporter:  thomask       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Media         |     Version:  4.2
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by jnz31):

 seems like they updated this function by adding the 'url' parameter (i
 have wp 4.3.1 installed), but that one is wrong too, since it's missing
 the path to the correct folder. this is what i have, the whole "wp-
 content/uploads/YYYY/MM" is missing:



 {{{
 [sizes] => Array
         (
             [thumbnail] => Array
                 (
                     [file] => 252005701-150x150.jpg
                     [width] => 150
                     [height] => 150
                     [mime-type] => image/jpeg
                     [path] => 2015/09/252005701-150x150.jpg
                     [url] => http://example.com/252005701-150x150.jpg
                 )
 ...
 }}}

 only option i see here is to get the upload directory and glue it to the
 path like so:


 {{{
 $img = wp_get_attachment_metadata( $img );
 $upload_dir = wp_upload_dir()['baseurl'];
 echo '<div class="full"><img src="' . $upload_dir .
 $img['sizes']['thumbnail']['url'] . '" alt="" />';
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/32117#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list