[wp-trac] [WordPress Trac] #55406: shorcodes don't work inside srcset attribute

WordPress Trac noreply at wordpress.org
Wed Mar 16 21:54:43 UTC 2022

#55406: shorcodes don't work inside srcset attribute
 Reporter:  XXVII         |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Shortcodes    |    Version:  5.8.3
 Severity:  normal        |   Keywords:
  Focuses:                |
 I have a simple shortcodes which replaces [uploads_directory] with the
 actual path.
 It doesn't work if I put it in a srcset attribute, while it works fine in
 a src attribute.

 <!-- this doesn't work -->
 <img srcset="[uploads_directory]/2022/03/image.webp 1x,
 [uploads_directory]/2022/03/image at 2x.webp 2x" />

 <!-- this is ok -->
 <img src="[uploads_directory]/2022/03/image.svg" />

 This is the code of the shortcode function
 function insert_get_uploads_directory() {
         $directory = wp_upload_dir();
         return $directory['baseurl'];
 add_shortcode( 'uploads_directory', 'insert_get_uploads_directory' );

Ticket URL: <https://core.trac.wordpress.org/ticket/55406>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list