Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#54170 closed defect (bug) (duplicate)

wp_kses_allowed_html stripping picture tags

Reported by: shaneonabike's profile shaneonabike Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Formatting Keywords:
Focuses: Cc:


Since the latest release of wp_kses_allowed_html it would appear that the function is stripping picture tags. I don't really understand why these are considered invalid. Specifically: picture, source, media and srcset.

My scenario is to provide better image rendering than the default setup by WordPress so I generate a <picture> tag.

Is it possible to add these to allowed html rather than requiring folks to create a custom filter as I have created below:

function kses_filter_allowed_html($allowed, $context) {
  if (is_array($context)) return $allowed;

  if ($context == 'post') {
    $allowed['picture'] = true;
    $allowed['source']['media'] = true;
    $allowed['source']['srcset'] = true;
  return $allowed;

Change History (3)

#1 @joyously
3 years ago

Were they there before?
I would question why hgroup is there, but meter, noscript, output, progress, and wbr are not.
And why is title in the list?

#2 @shaneonabike
3 years ago

Great question! This never seemed to happen previously so either a plugin I was using started using this which stripped it or it was added.

Regardless, I think that picture is still a valid tag right, and highly supported at this point.

#3 @SergeyBiryukov
3 years ago

  • Component changed from General to Formatting
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi there, welcome to WordPress Trac!

Thanks for the report, we're already tracking this issue in #29807.

Note: See TracTickets for help on using tickets.