* @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).
*