WordPress.org

Make WordPress Core

Changeset 36376


Ignore:
Timestamp:
01/22/2016 01:18:30 AM (4 years ago)
Author:
azaozz
Message:

TinyMCE: remove the srcset and sizes attributes (if any) after replacing or editing an image.

See #35434.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js

    r36352 r36376  
    354354        var classes, className, node, html, parent, wrap, linkNode,
    355355            captionNode, dd, dl, id, attrs, linkAttrs, width, height, align,
     356            $imageNode, srcset, src,
    356357            dom = editor.dom;
    357358
     
    487488            parent.appendChild( node );
    488489            dom.remove( captionNode );
     490        }
     491
     492        $imageNode = editor.$( imageNode );
     493        srcset = $imageNode.attr( 'srcset' );
     494        src = $imageNode.attr( 'src' );
     495
     496        // Remove srcset and sizes if the image file was edited or the image was replaced.
     497        if ( srcset && src ) {
     498            src = src.replace( /[?#].*/, '' );
     499
     500            if ( srcset.indexOf( src ) === -1 ) {
     501                $imageNode.attr( 'srcset', null ).attr( 'sizes', null );
     502            }
    489503        }
    490504
Note: See TracChangeset for help on using the changeset viewer.