Ticket #24449: 24449.3.diff
| File 24449.3.diff, 7.0 KB (added by , 13 years ago) |
|---|
-
wp-includes/js/media-editor.js
45 45 props.title = props.title || attachment.title; 46 46 47 47 link = props.link || defaultProps.link || getUserSetting( 'urlbutton', 'file' ); 48 if ( 'file' === link )48 if ( 'file' === link || 'embed' === link ) 49 49 linkUrl = attachment.url; 50 50 else if ( 'post' === link ) 51 51 linkUrl = attachment.link; … … 97 97 }, 98 98 99 99 audio: function( props, attachment ) { 100 var shortcode, html; 101 102 props = wp.media.string.props( props, attachment ); 103 shortcode = {}; 104 105 if ( props.mime ) { 106 switch ( props.mime ) { 107 case 'audio/mpeg': 108 if ( attachment.url.indexOf( 'mp3' ) ) 109 shortcode.mp3 = attachment.url; 110 else if ( attachment.url.indexOf( 'm4a' ) ) 111 shortcode.m4a = attachment.url; 112 break; 113 case 'audio/mp3': 114 shortcode.mp3 = attachment.url; 115 break; 116 case 'audio/m4a': 117 shortcode.m4a = attachment.url; 118 break; 119 case 'audio/wav': 120 shortcode.wav = attachment.url; 121 break; 122 case 'audio/ogg': 123 shortcode.ogg = attachment.url; 124 break; 125 case 'audio/x-ms-wma': 126 case 'audio/wma': 127 shortcode.wma = attachment.url; 128 break; 129 default: 130 // Render unsupported audio files as links. 131 return wp.media.string.link( props ); 132 } 133 } 134 135 html = wp.shortcode.string({ 136 tag: 'audio', 137 attrs: shortcode 138 }); 139 140 return html; 100 return wp.media.string._audioVideo( 'audio', props, attachment ); 141 101 }, 142 102 143 103 video: function( props, attachment ) { 144 var shortcode, html; 104 return wp.media.string._audioVideo( 'video', props, attachment ); 105 }, 145 106 107 _audioVideo: function( type, props, attachment ) { 108 var shortcode, html, extension; 109 146 110 props = wp.media.string.props( props, attachment ); 111 if ( props.link !== 'embed' ) 112 return wp.media.string.link( props ); 147 113 148 114 shortcode = {}; 149 115 150 if ( attachment.width ) 151 shortcode.width = attachment.width; 116 if ( 'video' === type ) { 117 if ( attachment.width ) 118 shortcode.width = attachment.width; 152 119 153 if ( attachment.height ) 154 shortcode.height = attachment.height; 120 if ( attachment.height ) 121 shortcode.height = attachment.height; 122 } 155 123 156 if ( props.mime ) { 157 switch ( props.mime ) { 158 case 'video/mp4': 159 shortcode.mp4 = attachment.url; 160 break; 161 case 'video/m4v': 162 shortcode.m4v = attachment.url; 163 break; 164 case 'video/webm': 165 shortcode.webm = attachment.url; 166 break; 167 case 'video/ogg': 168 shortcode.ogv = attachment.url; 169 break; 170 case 'video/x-ms-wmv': 171 case 'video/wmv': 172 case 'video/asf': 173 shortcode.wmv = attachment.url; 174 break; 175 case 'video/flv': 176 case 'video/x-flv': 177 shortcode.flv = attachment.url; 178 break; 179 } 124 extension = attachment.filename.split('.').pop(); 125 126 if ( _.contains( wp.media.view.settings.embedExts, extension ) ) { 127 shortcode[extension] = attachment.url; 128 } else { 129 // Render unsupported audio and video files as links. 130 return wp.media.string.link( props ); 180 131 } 181 132 182 133 html = wp.shortcode.string({ 183 tag: 'video',134 tag: type, 184 135 attrs: shortcode 185 136 }); 186 137 -
wp-includes/js/media-views.js
449 449 var displays = this._displays; 450 450 451 451 if ( ! displays[ attachment.cid ] ) 452 displays[ attachment.cid ] = new Backbone.Model( this. _defaultDisplaySettings);452 displays[ attachment.cid ] = new Backbone.Model( this.defaultDisplaySettings( attachment ) ); 453 453 454 454 return displays[ attachment.cid ]; 455 455 }, 456 456 457 defaultDisplaySettings: function( attachment ) { 458 settings = this._defaultDisplaySettings; 459 if ( settings.canEmbed = this.canEmbed( attachment ) ) 460 settings.link = 'embed'; 461 return settings; 462 }, 463 464 canEmbed: function( attachment ) { 465 var type = attachment.get('type'); 466 if ( type !== 'audio' && type !== 'video' ) 467 return false; 468 469 return _.contains( media.view.settings.embedExts, attachment.get('filename').split('.').pop() ); 470 }, 471 457 472 syncSelection: function() { 458 473 var selection = this.get('selection'), 459 474 manager = this.frame._selection; … … 3666 3681 $input = this.$('.link-to-custom'), 3667 3682 attachment = this.options.attachment; 3668 3683 3669 if ( 'none' === linkTo || ( ! attachment && 'custom' !== linkTo ) ) {3684 if ( 'none' === linkTo || 'embed' === linkTo || ( ! attachment && 'custom' !== linkTo ) ) { 3670 3685 $input.hide(); 3671 3686 return; 3672 3687 } -
wp-includes/media-template.php
281 281 282 282 <div class="setting"> 283 283 <label> 284 <span><?php _e('Link To'); ?></span> 284 <# if ( data.model.canEmbed ) { #> 285 <span><?php _e('Embed or Link'); ?></span> 286 <# } else { #> 287 <span><?php _e('Link To'); ?></span> 288 <# } #> 289 285 290 <select class="link-to" 286 291 data-setting="link" 287 <# if ( data.userSettings ) { #>292 <# if ( data.userSettings && ! data.model.canEmbed ) { #> 288 293 data-user-setting="urlbutton" 289 294 <# } #>> 290 295 291 <option value="custom"> 292 <?php esc_attr_e('Custom URL'); ?> 296 <# if ( data.model.canEmbed && 'audio' === data.type ) { #> 297 <option value="embed" selected> 298 <?php esc_attr_e('Embed Audio Player'); ?> 293 299 </option> 300 <option value="file"> 301 <# } else if ( data.model.canEmbed && 'video' === data.type ) { #> 302 <option value="embed" selected> 303 <?php esc_attr_e('Embed Video Player'); ?> 304 </option> 305 <option value="file"> 306 <# } else { #> 294 307 <option value="file" selected> 308 <# } #> 309 <# if ( data.model.canEmbed ) { #> 310 <?php esc_attr_e('Link to Media File'); ?> 311 <# } else { #> 295 312 <?php esc_attr_e('Media File'); ?> 313 <# } #> 296 314 </option> 297 315 <option value="post"> 316 <# if ( data.model.canEmbed ) { #> 317 <?php esc_attr_e('Link to Attachment Page'); ?> 318 <# } else { #> 298 319 <?php esc_attr_e('Attachment Page'); ?> 320 <# } #> 299 321 </option> 322 <# if ( 'image' === data.type ) { #> 323 <option value="custom"> 324 <?php esc_attr_e('Custom URL'); ?> 325 </option> 300 326 <option value="none"> 301 327 <?php esc_attr_e('None'); ?> 302 328 </option> 329 <# } #> 303 330 </select> 304 331 </label> 305 332 <input type="text" class="link-to-custom" data-setting="linkUrl" /> -
wp-includes/media.php
1753 1753 'id' => 0, 1754 1754 ), 1755 1755 'defaultProps' => $props, 1756 'embedExts' => array_merge( wp_get_audio_extensions(), wp_get_video_extensions() ), 1756 1757 ); 1757 1758 1758 1759 $post = null;