Ticket #15490: 15490.4.diff
File 15490.4.diff, 4.2 KB (added by , 11 years ago) |
---|
-
src/wp-admin/includes/ajax-actions.php
2311 2311 * @since 3.5.0 2312 2312 */ 2313 2313 function wp_ajax_send_link_to_editor() { 2314 global $post, $wp_embed; 2315 2314 2316 check_ajax_referer( 'media-send-to-editor', 'nonce' ); 2315 2317 2316 2318 if ( ! $src = wp_unslash( $_POST['src'] ) ) … … 2325 2327 if ( ! $title = trim( wp_unslash( $_POST['title'] ) ) ) 2326 2328 $title = wp_basename( $src ); 2327 2329 2328 $html = ''; 2329 if ( $title ) 2330 $post = get_post( isset( $_POST['post_id'] ) ? $_POST['post_id'] : 0 ); 2331 // ping WordPress for an embed 2332 $check_embed = $wp_embed->run_shortcode( '[embed]'. $src .'[/embed]' ); 2333 // fallback that WordPress creates when no oEmbed was found 2334 $fallback = $wp_embed->maybe_make_link( $src ); 2335 2336 if ( $check_embed !== $fallback ) { 2337 // TinyMCE view for [embed] will parse this 2338 $html = '[embed]' . $src . '[/embed]'; 2339 } elseif ( $title ) { 2330 2340 $html = '<a href="' . esc_url( $src ) . '">' . $title . '</a>'; 2341 } else { 2342 $html = ''; 2343 } 2331 2344 2332 2345 // Figure out what filter to run: 2333 2346 $type = 'file'; -
src/wp-includes/js/media-views.js
6144 6144 }, 6145 6145 6146 6146 initialize: function() { 6147 this.$input = $('<input />').attr( 'type', 'text' ).val( this.model.get('url') );6147 this.$input = $('<input id="embed-url-field" />').attr( 'type', 'text' ).val( this.model.get('url') ); 6148 6148 this.input = this.$input[0]; 6149 6149 6150 6150 this.spinner = $('<span class="spinner" />')[0]; … … 6200 6200 */ 6201 6201 media.view.EmbedLink = media.view.Settings.extend({ 6202 6202 className: 'embed-link-settings', 6203 template: media.template('embed-link-settings') 6203 template: media.template('embed-link-settings'), 6204 6205 initialize: function() { 6206 this.spinner = $('<span class="spinner" />'); 6207 this.$el.append( this.spinner[0] ); 6208 this.listenTo( this.model, 'change:url', this.updateoEmbed ); 6209 }, 6210 6211 updateoEmbed: function() { 6212 var url = this.model.get( 'url' ); 6213 6214 this.$('.setting.title').show(); 6215 // clear out previous results 6216 this.$('.embed-container').hide().find('.embed-preview').html(''); 6217 6218 // only proceed with embed if the field contains more than 6 characters 6219 if ( url && url.length < 6 ) { 6220 return; 6221 } 6222 6223 this.spinner.show(); 6224 6225 setTimeout( _.bind( this.fetch, this ), 500 ); 6226 }, 6227 6228 fetch: function() { 6229 // check if they haven't typed in 500 ms 6230 if ( $('#embed-url-field').val() !== this.model.get('url') ) { 6231 return; 6232 } 6233 6234 wp.ajax.send( 'filter-content', { 6235 data : { 6236 post_ID: media.view.settings.post.id, 6237 content: this.model.get('url') 6238 } 6239 } ).done( _.bind( this.renderoEmbed, this ) ); 6240 }, 6241 6242 renderoEmbed: function(html) { 6243 this.spinner.hide(); 6244 6245 this.$('.setting.title').hide(); 6246 this.$('.embed-container').show().find('.embed-preview').html( html ); 6247 } 6204 6248 }); 6205 6249 6206 6250 /** -
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"> -
src/wp-includes/css/media-views.css
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;