Changeset 31868
- Timestamp:
- 03/24/2015 01:32:17 AM (10 years ago)
- Location:
- trunk/src/wp-admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-press-this.php
r31837 r31868 1081 1081 $site_data = array( 1082 1082 'v' => ! empty( $data['v'] ) ? $data['v'] : '', 1083 'u' => ! empty( $data['u'] ) ? $data['u'] : '', 1083 1084 'hasData' => ! empty( $data ), 1084 1085 ); -
trunk/src/wp-admin/js/press-this.js
r31807 r31868 195 195 * @param link string Optional destination link, for images (defaults to src) 196 196 */ 197 function insertSelectedMedia( type, src, link) {198 var newContent = '';197 function insertSelectedMedia( $element ) { 198 var src, link, newContent = ''; 199 199 200 200 if ( ! editor ) { … … 202 202 } 203 203 204 src = checkUrl( src);205 link = checkUrl( link);206 207 if ( 'img' === type) {204 src = checkUrl( $element.attr( 'data-wp-src' ) || '' ); 205 link = checkUrl( data.u ); 206 207 if ( $element.hasClass( 'is-image' ) ) { 208 208 if ( ! link ) { 209 209 link = src; 210 210 } 211 211 212 newContent = '<a href="' + link + '"><img class="alignnone size-full" src="' + src + '" /></a> \n';212 newContent = '<a href="' + link + '"><img class="alignnone size-full" src="' + src + '" /></a>'; 213 213 } else { 214 newContent = '[embed]' + src + '[/embed] \n';214 newContent = '[embed]' + src + '[/embed]'; 215 215 } 216 216 217 217 if ( ! hasSetFocus ) { 218 editor.focus(); 219 } 220 221 editor.execCommand( 'mceInsertContent', false, newContent ); 222 hasSetFocus = true; 218 editor.setContent( '<p>' + newContent + '</p>' + editor.getContent() ); 219 } else { 220 editor.execCommand( 'mceInsertContent', false, newContent ); 221 } 223 222 } 224 223 … … 335 334 var $element = $mediaThumbWrap.clone().addClass( 'is-image' ); 336 335 337 $element. css( 'background-image', 'url(' + displaySrc + ')' )336 $element.attr( 'data-wp-src', src ).css( 'background-image', 'url(' + displaySrc + ')' ) 338 337 .find( 'span' ).text( __( 'suggestedImgAlt' ).replace( '%d', i + 1 ) ); 339 338 340 $element.on( 'click keypress', function ( event ) { 341 if ( event.type === 'click' || event.keyCode === 13 ) { 342 insertSelectedMedia( 'img', src, data.u ); 343 } 344 } ).appendTo( $mediaList ); 339 $mediaList.append( $element ); 345 340 } 346 341 … … 379 374 } 380 375 381 $element. find( 'span' ).text( __( 'suggestedEmbedAlt' ).replace( '%d', i + 1 ) );376 $element.attr( 'data-wp-src', src ).find( 'span' ).text( __( 'suggestedEmbedAlt' ).replace( '%d', i + 1 ) ); 382 377 383 378 if ( displaySrc ) { … … 385 380 } 386 381 387 $element.on( 'click keypress', function ( event ) { 388 if ( event.type === 'click' || event.keyCode === 13 ) { 389 insertSelectedMedia( 'embed', src ); 390 } 391 } ).appendTo( $mediaList ); 392 382 $mediaList.append( $element ); 393 383 found++; 394 384 } ); … … 580 570 hasSetFocus = true; 581 571 } ); 572 }).on( 'click.press-this keypress.press-this', '.suggested-media-thumbnail', function( event ) { 573 if ( event.type === 'click' || event.keyCode === 13 ) { 574 insertSelectedMedia( $( this ) ); 575 } 582 576 }); 583 577
Note: See TracChangeset
for help on using the changeset viewer.