[wp-trac] [WordPress Trac] #29807: add support for picture element and srcset attribute on img in wp_kses

WordPress Trac noreply at wordpress.org
Mon Aug 7 07:24:14 UTC 2017


#29807: add support for picture element and srcset attribute on img in wp_kses
-------------------------------------------------+-------------------------
 Reporter:  mattheu                              |       Owner:
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  Future
Component:  Formatting                           |  Release
 Severity:  normal                               |     Version:
 Keywords:  has-patch has-unit-tests needs-      |  Resolution:
  refresh                                        |     Focuses:
-------------------------------------------------+-------------------------

Comment (by peterwilsoncc):

 Replying to [comment:22 drrobotnik]:
 > What's the right approach to refactor? My patch was a small refactor on
 wp_kses_hair. I started with formatting but stopped because I didn't want
 to go down the rabbit hole and not have the patch accepted.

 Apologies for missing your question earlier, the full details can be found
 in [http://w3c.github.io/html/semantics-embedded-content.html#element-
 attrdef-img-srcset the srcset spec] but it's a little dry.

 A `srcset` is made up of one or more image candidates separated by commas,
 each image candidate needs to be validated separately `srcset='candidate
 1, candidate 2, candidate 3'`.

 To validate each candidate:
 * split into sections on whitespace
 * discard image candidate if there are three or more sections
 * the first section should validate as a URL
 * the second section is optional and should validate as a number followed
 by a letter.
 * if either section is invalid, the entire image candidate should be
 discarded

 Unfortunately it's a rather complicated attribute. The validation of the
 URL matches the same validation used for the `href`, `src` and other URL
 attributes.

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


More information about the wp-trac mailing list