Changes from branches/2.6/wp-admin/press-this.php at r8552 to trunk/wp-admin/press-this.php at r8332
- File:
-
- 1 edited
-
trunk/wp-admin/press-this.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/press-this.php
r8552 r8332 35 35 36 36 foreach( (array) $_REQUEST['photo_src'] as $key => $image) { 37 37 // escape quote for matching 38 $quoted = preg_quote2($image); 39 38 40 // see if files exist in content - we don't want to upload non-used selected files. 39 if( strpos($_REQUEST['content'], $ image) !== false ) {41 if( strpos($_REQUEST['content'], $quoted) !== false ) { 40 42 $upload = media_sideload_image($image, $post_ID, $_REQUEST['photo_description'][$key]); 41 42 43 // Replace the POSTED content <img> with correct uploaded ones. 43 // escape quote for matching44 $quoted = preg_quote2($image);45 44 if( !is_wp_error($upload) ) $content = preg_replace('/<img ([^>]*)src=(\"|\')'.$quoted.'(\2)([^>\/]*)\/*>/is', $upload, $content); 46 45 } … … 185 184 $host = parse_url($uri); 186 185 187 $pattern = '/<img ([^>]*)src=(\"|\')([^<>]+?\.(png|jpeg|jpg|jpe|gif) )[^<>\'\"]*(\2)([^>\/]*)\/*>/is';186 $pattern = '/<img ([^>]*)src=(\"|\')([^<>]+?\.(png|jpeg|jpg|jpe|gif)[^<>\'\"]*)(\2)([^>\/]*)\/*>/is'; 188 187 preg_match_all($pattern, $content, $matches); 189 188 190 189 if ( empty($matches[1]) ) return ''; 191 190 192 191 $sources = array(); 193 192 foreach ($matches[3] as $src) { 194 // if no http in url195 193 if(strpos($src, 'http') === false) 196 // if it doesn't have a relative uri 197 if( strpos($src, '../') === false && strpos($src, './') === false && strpos($src, '/') === true) 194 if(strpos($src, '../') === false && strpos($src, './') === false) 198 195 $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src); 199 196 else 200 $src = 'http://'.str_replace('//','/', $host['host'].'/'. dirname($host['path']).'/'.$src);201 197 $src = 'http://'.str_replace('//','/', $host['host'].'/'.$host['path'].'/'.$src); 198 202 199 $sources[] = clean_url($src); 203 200 } … … 250 247 251 248 function pick(img, desc) { 252 if (img) { 253 if('object' == typeof jQuery('.photolist input') && jQuery('.photolist input').length != 0)length = jQuery('.photolist input').length;249 if (img) { 250 length = jQuery('.photolist input').length; 254 251 if(length == 0) length = 1; 255 252 jQuery('.photolist').append('<input name="photo_src[' + length + ']" value="' + img +'" type="hidden"/>'); 256 253 jQuery('.photolist').append('<input name="photo_description[' + length + ']" value="' + desc +'" type="hidden"/>'); 257 append_editor("\n\n" + '<p><img src="' + img +'" alt="' + desc + '" class="aligncenter"/></p>');254 append_editor("\n\n" + '<p><img src="' + img +'" alt="' + desc + '" /></p>'); 258 255 } 259 256 tinyMCE.activeEditor.resizeToContent(); … … 270 267 271 268 jQuery(document).ready(function() { 272 jQuery('#extra_fields').html('<div class="photolist"></div><small id="photo_directions"><?php _e("Click images to select:") ?> <span><a href="#" id="photo_add_url" class="thickbox"><?php _e("Add from URL") ?> +</a></span></small><div class="titlewrap"><div id="img_container"></div></div>');273 269 jQuery('#img_container').html(strtoappend); 274 270 jQuery('#photo_add_url').attr('href', '?ajax=thickbox_url&height=200&width=500'); … … 280 276 281 277 if($_REQUEST['ajax'] == 'photo') { ?> 282 278 <div class="photolist"></div> 279 280 <small id="photo_directions"><?php _e('Click images to select:') ?> <span><a href="#" id="photo_add_url" class="thickbox"><?php _e('Add from URL') ?> +</a></span></small> 281 282 <div class="titlewrap"> 283 <div id="img_container"></div> 284 </div> 283 285 <?php die; 284 286 } … … 321 323 language : "<?php echo $language; ?>", 322 324 width: "100%", 323 height: "300",324 325 theme : "advanced", 325 326 theme_advanced_buttons1 : "bold,italic,underline,blockquote,separator,strikethrough,bullist,numlist,undo,redo,link,unlink", … … 445 446 jQuery('#extra_fields').show(); 446 447 jQuery('#extra_fields').before('<h2 id="waiting"><img src="images/loading.gif" alt="" /><?php echo js_escape( __( 'Loading...' ) ); ?></h2>'); 448 jQuery('#extra_fields').load('<?php echo clean_url($_SERVER['PHP_SELF']).'/?ajax=photo&u='.attribute_escape($url); ?>'); 447 449 jQuery.ajax({ 448 450 type: "GET", … … 471 473 <?php } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { ?> 472 474 show('video'); 473 <?php } elseif ( preg_match("/flickr\.com/i", $url) ) { ?>475 <?php } elseif ( preg_match("/flickr\.com/i", $url) ) { ?> 474 476 show('photo'); 475 477 <?php } ?> … … 504 506 <h2 id="content_type"><label for="content"><?php _e('Post') ?></label></h2> 505 507 <div class="editor-container"> 506 <textarea name="content" id="content" style="width:100%;" class="mceEditor" rows="15"><?php if ($selection) { echo wp_richedit_pre($selection); } ?><a href="<?php echo $url ?>"><?php echo $title; ?></a>.</textarea>508 <textarea name="content" id="content" style="width:100%;" class="mceEditor"><?php if ($selection) { echo wp_richedit_pre($selection); } ?><a href="<?php echo $url ?>"><?php echo $title; ?></a>.</textarea> 507 509 </div> 508 510 </div>
Note:
See TracChangeset
for help on using the changeset viewer.