mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00: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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user