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

See #35434.
Built from https://develop.svn.wordpress.org/trunk@36376


git-svn-id: http://core.svn.wordpress.org/trunk@36343 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2016-01-22 01:19:25 +00:00
parent 496bde4e77
commit ca1906b159
4 changed files with 16 additions and 2 deletions

View File

@ -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,

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.5-alpha-36375';
$wp_version = '4.5-alpha-36376';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.