Ticket #24449: 24449.2.diff
| File 24449.2.diff, 6.9 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 ( props.embed !== 'embed' 49 && ( props.type === 'video' || props.type === 'audio' ) 50 && _.contains( wp.media.view.settings.embedExts, attachment.filename.split('.').pop() ) ) 51 link = props.embed; 52 48 53 if ( 'file' === link ) 49 54 linkUrl = attachment.url; 50 55 else if ( 'post' === link ) … … 97 102 }, 98 103 99 104 audio: function( props, attachment ) { 100 var shortcode, html ;105 var shortcode, html, extension; 101 106 102 107 props = wp.media.string.props( props, attachment ); 108 if ( props.embed !== 'embed' ) 109 return wp.media.string.link( props ); 110 103 111 shortcode = {}; 104 112 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 } 113 if ( 'video' === attachment.type ) { 114 if ( attachment.width ) 115 shortcode.width = attachment.width; 116 117 if ( attachment.height ) 118 shortcode.height = attachment.height; 133 119 } 134 120 135 html = wp.shortcode.string({ 136 tag: 'audio', 137 attrs: shortcode 138 }); 121 extension = attachment.filename.split('.').pop(); 139 122 140 return html; 141 }, 142 143 video: function( props, attachment ) { 144 var shortcode, html; 145 146 props = wp.media.string.props( props, attachment ); 147 148 shortcode = {}; 149 150 if ( attachment.width ) 151 shortcode.width = attachment.width; 152 153 if ( attachment.height ) 154 shortcode.height = attachment.height; 155 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 } 123 if ( _.contains( wp.media.view.settings.embedExts, extension ) ) { 124 shortcode[extension] = attachment.url; 125 } else { 126 // Render unsupported audio and video files as links. 127 return wp.media.string.link( props ); 180 128 } 181 129 182 130 html = wp.shortcode.string({ 183 tag: 'video' ,131 tag: 'video' === attachment.type ? 'video' : 'audio', 184 132 attrs: shortcode 185 133 }); 186 134 … … 187 135 return html; 188 136 }, 189 137 138 video: function( props, attachment ) { 139 return wp.media.string.audio( props, attachment ); 140 }, 141 190 142 image: function( props, attachment ) { 191 143 var img = {}, 192 144 options, classes, shortcode, html; -
wp-includes/js/media-views.js
441 441 this._defaultDisplaySettings = { 442 442 align: defaultProps.align || getUserSetting( 'align', 'none' ), 443 443 size: defaultProps.size || getUserSetting( 'imgsize', 'medium' ), 444 link: defaultProps.link || getUserSetting( 'urlbutton', 'file' ) 444 link: defaultProps.link || getUserSetting( 'urlbutton', 'file' ), 445 embed: 'embed' 445 446 }; 446 447 }, 447 448 … … 3652 3653 if ( attachment ) { 3653 3654 _.extend( this.options, { 3654 3655 sizes: attachment.get('sizes'), 3655 type: attachment.get('type') 3656 type: attachment.get('type'), 3657 canEmbed: this.canEmbed( attachment ) 3656 3658 }); 3657 3659 } 3658 3660 … … 3661 3663 return this; 3662 3664 }, 3663 3665 3666 canEmbed: function( attachment ) { 3667 var type = attachment.get('type'); 3668 if ( type !== 'audio' && type !== 'video' ) 3669 return false; 3670 3671 return _.contains( media.view.settings.embedExts, attachment.get('filename').split('.').pop() ); 3672 }, 3673 3664 3674 updateLinkTo: function() { 3665 3675 var linkTo = this.model.get('link'), 3666 3676 $input = this.$('.link-to-custom'), -
wp-includes/media-template.php
279 279 </label> 280 280 <# } #> 281 281 282 <# if ( data.canEmbed ) { #> 283 <label class="setting"> 284 <span><?php _e('Embed or Link'); ?></span> 285 <select class="embed-or-link" 286 data-setting="embed"> 287 <# if ( 'audio' === data.type ) { #> 288 <option value="embed" selected> 289 <?php esc_attr_e('Embed Audio Player'); ?> 290 </option> 291 <# } else { #> 292 <option value="embed" selected> 293 <?php esc_attr_e('Embed as Video Player'); ?> 294 </option> 295 <# } #> 296 <option value="file"> 297 <?php esc_attr_e('Link to Media File'); ?> 298 </option> 299 <option value="post"> 300 <?php esc_attr_e('Link to Attachment Page'); ?> 301 </option> 302 </select> 303 </label> 304 <# } else { #> 305 282 306 <div class="setting"> 283 307 <label> 284 308 <span><?php _e('Link To'); ?></span> … … 288 312 data-user-setting="urlbutton" 289 313 <# } #>> 290 314 315 <# if ( 'image' === data.type ) { #> 291 316 <option value="custom"> 292 317 <?php esc_attr_e('Custom URL'); ?> 293 318 </option> 319 <# } #> 294 320 <option value="file" selected> 295 321 <?php esc_attr_e('Media File'); ?> 296 322 </option> … … 297 323 <option value="post"> 298 324 <?php esc_attr_e('Attachment Page'); ?> 299 325 </option> 326 <# if ( 'image' === data.type ) { #> 300 327 <option value="none"> 301 328 <?php esc_attr_e('None'); ?> 302 329 </option> 330 <# } #> 303 331 </select> 304 332 </label> 305 333 <input type="text" class="link-to-custom" data-setting="linkUrl" /> 306 334 </div> 307 335 336 <# } #> 337 308 338 <# if ( 'undefined' !== typeof data.sizes ) { #> 309 339 <label class="setting"> 310 340 <span><?php _e('Size'); ?></span> -
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;