Ticket #35153: 35153.5.diff
| File 35153.5.diff, 2.4 KB (added by , 10 years ago) |
|---|
-
src/wp-includes/js/media-views.js
1214 1214 * @returns {Object} 1215 1215 */ 1216 1216 defaultDisplaySettings: function( attachment ) { 1217 var settings = this._defaultDisplaySettings; 1217 var settings = _.clone( this._defaultDisplaySettings ); 1218 1218 1219 if ( settings.canEmbed = this.canEmbed( attachment ) ) { 1219 1220 settings.link = 'embed'; 1221 } else if ( ! this.isImageAttachment( attachment ) && settings.link === 'none' ) { 1222 settings.link = 'file'; 1220 1223 } 1224 1221 1225 return settings; 1222 1226 }, 1223 1227 1224 1228 /** 1229 * Whether an attachment is image. 1230 * 1231 * @since 4.4.1 1232 * 1233 * @param {wp.media.model.Attachment} attachment 1234 * @returns {Boolean} 1235 */ 1236 isImageAttachment: function( attachment ) { 1237 // If uploading, we know the filename but not the mime type. 1238 if ( attachment.get('uploading') ) { 1239 return /\.(jpe?g|png|gif)$/i.test( attachment.get('filename') ); 1240 } 1241 1242 return attachment.get('type') === 'image'; 1243 }, 1244 1245 /** 1225 1246 * Whether an attachment can be embedded (audio or video). 1226 1247 * 1227 1248 * @since 3.6.0 -
src/wp-includes/js/media/controllers/library.js
171 171 * @returns {Object} 172 172 */ 173 173 defaultDisplaySettings: function( attachment ) { 174 var settings = this._defaultDisplaySettings; 174 var settings = _.clone( this._defaultDisplaySettings ); 175 175 176 if ( settings.canEmbed = this.canEmbed( attachment ) ) { 176 177 settings.link = 'embed'; 178 } else if ( ! this.isImageAttachment( attachment ) && settings.link === 'none' ) { 179 settings.link = 'file'; 177 180 } 181 178 182 return settings; 179 183 }, 180 184 181 185 /** 186 * Whether an attachment is image. 187 * 188 * @since 4.4.1 189 * 190 * @param {wp.media.model.Attachment} attachment 191 * @returns {Boolean} 192 */ 193 isImageAttachment: function( attachment ) { 194 // If uploading, we know the filename but not the mime type. 195 if ( attachment.get('uploading') ) { 196 return /\.(jpe?g|png|gif)$/i.test( attachment.get('filename') ); 197 } 198 199 return attachment.get('type') === 'image'; 200 }, 201 202 /** 182 203 * Whether an attachment can be embedded (audio or video). 183 204 * 184 205 * @since 3.6.0