Media: when inserting an attachment in the editor and it is not an image, ensure the link is set to something else than `none`.

Props eherman24, azaozz.
Fixes #35153 for 4.4.1.
Built from https://develop.svn.wordpress.org/branches/4.4@36167


git-svn-id: http://core.svn.wordpress.org/branches/4.4@36133 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2016-01-04 00:41:26 +00:00
parent 001e5d3951
commit c9c10c4752
3 changed files with 27 additions and 6 deletions

View File

@ -1214,13 +1214,34 @@ Library = wp.media.controller.State.extend({
* @returns {Object}
*/
defaultDisplaySettings: function( attachment ) {
var settings = this._defaultDisplaySettings;
var settings = _.clone( this._defaultDisplaySettings );
if ( settings.canEmbed = this.canEmbed( attachment ) ) {
settings.link = 'embed';
} else if ( ! this.isImageAttachment( attachment ) && settings.link === 'none' ) {
settings.link = 'file';
}
return settings;
},
/**
* Whether an attachment is image.
*
* @since 4.4.1
*
* @param {wp.media.model.Attachment} attachment
* @returns {Boolean}
*/
isImageAttachment: function( attachment ) {
// If uploading, we know the filename but not the mime type.
if ( attachment.get('uploading') ) {
return /\.(jpe?g|png|gif)$/i.test( attachment.get('filename') );
}
return attachment.get('type') === 'image';
},
/**
* Whether an attachment can be embedded (audio or video).
*

File diff suppressed because one or more lines are too long

View File

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