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