Make WordPress Core

Changes between Initial Version and Version 4 of Ticket #51417


Ignore:
Timestamp:
11/05/2020 10:31:39 AM (3 years ago)
Author:
SergeyBiryukov
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #51417

    • Property Keywords needs-patch added
    • Property Milestone changed from Awaiting Review to Future Release
  • Ticket #51417 – Description

    initial v4  
    11Hi,
    22We have new, way more efficient graphic formats coming - avif and webp. They are already supported by Firefox and Chrome. The recommended and backwards compatible method of inserting them is using a picture tag with an img fallback, for example:
    3 
    4   <picture>
    5   <source srcset="example.avif" type="image/avif">
    6   <source srcset="fallback.webp" type="image/webp">
    7   <img src="fallback.jpg" alt="AVIF example with WebP and JPEG fallback">
    8   </picture>
    9 
     3{{{
     4<picture>
     5<source srcset="example.avif" type="image/avif">
     6<source srcset="fallback.webp" type="image/webp">
     7<img src="fallback.jpg" alt="AVIF example with WebP and JPEG fallback">
     8</picture>
     9}}}
    1010Using the filter tiny_mce_before_init I can make TinyMCE accept the code if it is not surrounded by caption shortcode. Unfortunately the editor handles the [caption] code in javascript, the file is wp-includes/js/tinymce/plugins/wpeditimage/plugin.js
    1111and it has a filter:
    12 
    13                         img = c.match( /((?:<a [^>]+>)?<img [^>]+>(?:<\/a>)?)([\s\S]*)/i );
    14 
     12{{{
     13img = c.match( /((?:<a [^>]+>)?<img [^>]+>(?:<\/a>)?)([\s\S]*)/i );
     14}}}
    1515which removes everything except a and img tags. So <picture> and <source> become stripped. There is no filter nor configuration to modify how that JS works.
    1616