Ticket #15490: 15490.5.diff
File 15490.5.diff, 4.5 KB (added by , 11 years ago) |
---|
-
src/wp-admin/includes/ajax-actions.php
2309 2309 * @since 3.5.0 2310 2310 */ 2311 2311 function wp_ajax_send_link_to_editor() { 2312 global $post, $wp_embed; 2313 2312 2314 check_ajax_referer( 'media-send-to-editor', 'nonce' ); 2313 2315 2314 2316 if ( ! $src = wp_unslash( $_POST['src'] ) ) … … 2323 2325 if ( ! $title = trim( wp_unslash( $_POST['title'] ) ) ) 2324 2326 $title = wp_basename( $src ); 2325 2327 2326 $html = ''; 2327 if ( $title ) 2328 $post = get_post( isset( $_POST['post_id'] ) ? $_POST['post_id'] : 0 ); 2329 // ping WordPress for an embed 2330 $check_embed = $wp_embed->run_shortcode( '[embed]'. $src .'[/embed]' ); 2331 // fallback that WordPress creates when no oEmbed was found 2332 $fallback = $wp_embed->maybe_make_link( $src ); 2333 2334 if ( $check_embed !== $fallback ) { 2335 // TinyMCE view for [embed] will parse this 2336 $html = '[embed]' . $src . '[/embed]'; 2337 } elseif ( $title ) { 2328 2338 $html = '<a href="' . esc_url( $src ) . '">' . $title . '</a>'; 2339 } else { 2340 $html = ''; 2341 } 2329 2342 2330 2343 // Figure out what filter to run: 2331 2344 $type = 'file'; -
src/wp-includes/css/media-views.css
1583 1583 1584 1584 .media-frame .embed-url .spinner { 1585 1585 position: absolute; 1586 top: 16px;1586 top: 32px; 1587 1587 right: 26px; 1588 1588 } 1589 1589 … … 1594 1594 .embed-link-settings, 1595 1595 .embed-media-settings { 1596 1596 position: absolute; 1597 top: 60px;1597 top: 70px; 1598 1598 left: 0; 1599 1599 right: 0; 1600 1600 bottom: 0; … … 1602 1602 overflow: auto; 1603 1603 } 1604 1604 1605 .embed-preview img, .embed-preview iframe, .embed-preview embed { 1606 max-width: 100%; 1607 } 1608 1609 .embed-preview img { 1610 height: auto; 1611 } 1612 1605 1613 .image-details .media-modal { 1606 1614 left: 140px; 1607 1615 right: 140px; -
src/wp-includes/js/media-views.js
6150 6150 }, 6151 6151 6152 6152 initialize: function() { 6153 this.$input = $('<input />').attr( 'type', 'text' ).val( this.model.get('url') );6153 this.$input = $('<input id="embed-url-field" />').attr( 'type', 'text' ).val( this.model.get('url') ); 6154 6154 this.input = this.$input[0]; 6155 6155 6156 6156 this.spinner = $('<span class="spinner" />')[0]; … … 6206 6206 */ 6207 6207 media.view.EmbedLink = media.view.Settings.extend({ 6208 6208 className: 'embed-link-settings', 6209 template: media.template('embed-link-settings') 6209 template: media.template('embed-link-settings'), 6210 6211 initialize: function() { 6212 this.spinner = $('<span class="spinner" />'); 6213 this.$el.append( this.spinner[0] ); 6214 this.listenTo( this.model, 'change:url', this.updateoEmbed ); 6215 }, 6216 6217 updateoEmbed: function() { 6218 var url = this.model.get( 'url' ); 6219 6220 this.$('.setting.title').show(); 6221 // clear out previous results 6222 this.$('.embed-container').hide().find('.embed-preview').html(''); 6223 6224 // only proceed with embed if the field contains more than 6 characters 6225 if ( url && url.length < 6 ) { 6226 return; 6227 } 6228 6229 this.spinner.show(); 6230 6231 setTimeout( _.bind( this.fetch, this ), 500 ); 6232 }, 6233 6234 fetch: function() { 6235 // check if they haven't typed in 500 ms 6236 if ( $('#embed-url-field').val() !== this.model.get('url') ) { 6237 return; 6238 } 6239 6240 wp.ajax.send( 'parse-embed', { 6241 data : { 6242 post_ID: media.view.settings.post.id, 6243 content: '[embed]' + this.model.get('url') + '[/embed]' 6244 } 6245 } ).done( _.bind( this.renderoEmbed, this ) ); 6246 }, 6247 6248 renderoEmbed: function(html) { 6249 this.spinner.hide(); 6250 6251 this.$('.setting.title').hide(); 6252 this.$('.embed-container').show().find('.embed-preview').html( html ); 6253 } 6210 6254 }); 6211 6255 6212 6256 /** -
src/wp-includes/media-template.php
546 546 </script> 547 547 548 548 <script type="text/html" id="tmpl-embed-link-settings"> 549 <label class="setting ">550 <span><?php _e( 'Title'); ?></span>549 <label class="setting title"> 550 <span><?php _e( 'Title' ); ?></span> 551 551 <input type="text" class="alignment" data-setting="title" /> 552 552 </label> 553 <div class="embed-container" style="display: none;"> 554 <div class="embed-preview"></div> 555 </div> 553 556 </script> 554 557 555 558 <script type="text/html" id="tmpl-embed-image-settings">