From 5e1e5c53ec7675b364fd0786fc34600436d78b63 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 14 Mar 2014 12:59:28 +0000 Subject: [PATCH] In `media.model.PostMedia`, for these 2 scenarios: * `src` is set, and 'Add a Source' results in the same file (or a file with the same extension) being added * `src` is set, and 'Replace Audio|Video' is used, which will add a model property named by the attachment's extension ... call `model.unset( 'src' )`. See #27389. git-svn-id: https://develop.svn.wordpress.org/trunk@27536 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/media-models.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wp-includes/js/media-models.js b/src/wp-includes/js/media-models.js index 92517e23c3..2e406d7a3c 100644 --- a/src/wp-includes/js/media-models.js +++ b/src/wp-includes/js/media-models.js @@ -467,6 +467,10 @@ window.wp = window.wp || {}; this.attachment = attachment; this.extension = attachment.get('filename' ).split('.').pop(); + if ( this.get( 'src' ) && this.extension === this.get( 'src' ).split('.').pop() ) { + this.unset( 'src' ); + } + if ( _.contains( wp.media.view.settings.embedExts, this.extension ) ) { this.set( this.extension, this.attachment.get( 'url' ) ); } else { @@ -479,6 +483,7 @@ window.wp = window.wp || {}; this.setSource( attachment ); + this.unset( 'src' ); _.each( _.without( wp.media.view.settings.embedExts, this.extension ), function (ext) { self.unset( ext ); } );