[wp-trac] [WordPress Trac] #29807: add support for picture element and srcset attribute on img in wp_kses
WordPress Trac
noreply at wordpress.org
Sat Aug 30 16:54:04 UTC 2025
#29807: add support for picture element and srcset attribute on img in wp_kses
--------------------------------------+------------------------------
Reporter: mattheu | Owner: adamsilverstein
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 6.9
Component: Formatting | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses:
--------------------------------------+------------------------------
Comment (by oglekler):
Hi @adamsilverstein 👋
Right now I am not sure about fetchpriority and decoding 🤔 It looks fine.
But I tested purely your changes with the 6.8.1 version 😅 and I was
reluctant to update to the latest build 😒, and it turned out there are
some other changes in the kses.php in the Trunk branch as well, so I am
not sure.
But what I see is that {{{src}}} is perfectly fine (even if it is build
the same way), but URLs in {{{srcset}}} are getting modified with the
described result.
Function to build URLs:
{{{
function pref_get_cloud_image_src(
string $source,
int $w,
int $h = null,
int $q = 80, // Quality.
int $dpr = 1, // Device pixel ratio.
string $fit = 'crop', // Fitting. crop, scale-down, contain,
cover.
string $g = 'center' // Gravity. auto, center, top, right, bottom,
left.
): string {
$g = ( 'center' === $g ) ? '0.5x0.5' : $g;
$url = PREF_RESIZER_URL;
$args = [
'format' => 'auto',
'onerror' => 'redirect',
'quality' => $q,
'width' => $w,
'height' => $h,
'dpr' => $dpr,
'fit' => $fit,
'gravity' => $g,
];
$url .= str_replace( '&', ',', http_build_query( $args ) ); //
Without this resizer is returning an error 🤷♀️
return $url . '/' . esc_url( $source ); // This is the final url
🍄
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29807#comment:48>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list