mirror of
git://develop.git.wordpress.org/
synced 2025-02-24 08:33:35 +01:00
TinyMCE: remove the srcset
and sizes
attributes (if any) after replacing or editing an image.
See #35434. git-svn-id: https://develop.svn.wordpress.org/trunk@36376 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
710f2593cc
commit
10c8930278
@ -353,6 +353,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
function updateImage( imageNode, imageData ) {
|
||||
var classes, className, node, html, parent, wrap, linkNode,
|
||||
captionNode, dd, dl, id, attrs, linkAttrs, width, height, align,
|
||||
$imageNode, srcset, src,
|
||||
dom = editor.dom;
|
||||
|
||||
classes = tinymce.explode( imageData.extraClasses, ' ' );
|
||||
@ -488,6 +489,19 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
dom.remove( captionNode );
|
||||
}
|
||||
|
||||
$imageNode = editor.$( imageNode );
|
||||
srcset = $imageNode.attr( 'srcset' );
|
||||
src = $imageNode.attr( 'src' );
|
||||
|
||||
// Remove srcset and sizes if the image file was edited or the image was replaced.
|
||||
if ( srcset && src ) {
|
||||
src = src.replace( /[?#].*/, '' );
|
||||
|
||||
if ( srcset.indexOf( src ) === -1 ) {
|
||||
$imageNode.attr( 'srcset', null ).attr( 'sizes', null );
|
||||
}
|
||||
}
|
||||
|
||||
if ( wp.media.events ) {
|
||||
wp.media.events.trigger( 'editor:image-update', {
|
||||
editor: editor,
|
||||
|
Loading…
x
Reference in New Issue
Block a user