Make WordPress Core

Opened 3 years ago

Last modified 2 years ago

#55406 new defect (bug)

Shortcodes don't work inside srcset attribute

Reported by: xxvii's profile XXVII Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.8.3
Component: Shortcodes Keywords:
Focuses: Cc:

Description

Hello,
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@2x.webp 2x" />

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

This is the code of the shortcode function

<?php
function insert_get_uploads_directory() {
        $directory = wp_upload_dir();
        return $directory['baseurl'];
}
add_shortcode( 'uploads_directory', 'insert_get_uploads_directory' );

Change History (1)

#1 @XXVII
2 years ago

  • Summary changed from shorcodes don't work inside srcset attribute to Shortcodes don't work inside srcset attribute
Note: See TracTickets for help on using tickets.