[wp-trac] [WordPress Trac] #34757: Add filter, probably image_downsize, for image urls in wp_calculate_image_srcset()

WordPress Trac noreply at wordpress.org
Sat Nov 21 12:16:00 UTC 2015


#34757: Add filter, probably image_downsize, for image urls in
wp_calculate_image_srcset()
--------------------------+------------------------------
 Reporter:  klihelp       |       Owner:
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Media         |     Version:  trunk
 Severity:  normal        |  Resolution:  worksforme
 Keywords:                |     Focuses:
--------------------------+------------------------------
Changes (by klihelp):

 * status:  new => closed
 * resolution:   => worksforme


Comment:

 Thanks!

 {{{
 // Change imges urls in scrset

 function re_calculate_image_srcset($sources, $size_array, $image_src,
 $image_meta, $attachment_id) {

         if ( eazyest_folderbase()->is_gallery_image( $attachment_id ) ) {
                 $uploads_url = wp_upload_dir();
                 $uploads_url = trailingslashit( $uploads_url['baseurl'] );

                 foreach ($sources as $key => $value) {
                         $sources[$key]['url'] = str_replace($uploads_url,
 eazyest_gallery()->address(), $value['url'] );
                 }
         }

         return $sources;
 }
 add_filter('wp_calculate_image_srcset', 're_calculate_image_srcset', 100,
 5);


 }}}

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


More information about the wp-trac mailing list