Changeset 8172
- Timestamp:
- 06/23/08 21:16:39 (5 months ago)
- Files:
-
- trunk/wp-admin/includes/media.php (modified) (2 diffs)
- trunk/wp-admin/press-this.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wp-admin/includes/media.php
r8169 r8172 152 152 if ( !is_wp_error($id) ) { 153 153 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); 154 return $src; 155 } 156 154 return $url; 155 } 157 156 return $id; 158 159 157 } 160 158 … … 322 320 323 321 $id = media_handle_sideload($file_array, $post_id, $desc); 322 $src = $id; 323 324 324 unset($file_array); 325 325 326 326 if ( is_wp_error($id) ) { 327 327 $errors['upload_error'] = $id; 328 328 return $id; 329 } else { 330 $src = $id; 331 } 332 } 333 334 if (!empty($src) && !strpos($src, '://') ) { 335 $src = "http://$src"; 329 } 330 } 331 332 if ( !empty($src) ) { 333 if ( !strpos($src, '://') ) 334 $src = "http://$src"; 336 335 $alt = @$desc; 337 }338 if ( !empty($src) ) {339 336 $html = "<img src='$src' alt='$alt' />"; 340 337 return $html; trunk/wp-admin/press-this.php
r8169 r8172 5 5 6 6 <?php 7 8 function preg_quote2($string) { 9 return str_replace('/', '\/', preg_quote($string)); 10 } 7 11 function press_it() { 8 #define some basic variables12 // define some basic variables 9 13 $quick['post_status'] = $_REQUEST['post_status']; 10 14 $quick['post_category'] = $_REQUEST['post_category']; … … 13 17 $quick['post_content'] = ''; 14 18 15 #insert the post with nothing in it, to get an ID19 // insert the post with nothing in it, to get an ID 16 20 $post_ID = wp_insert_post($quick, true); 17 21 … … 24 28 25 29 case 'photo': 26 foreach($_REQUEST['photo_src'] as $key => $data) { 30 $content = $_REQUEST['content']; 31 32 foreach($_REQUEST['photo_src'] as $key => $image) { 27 33 #quote for matching 28 $quoted = str_replace('/', '\/', preg_quote($data));34 $quoted = preg_quote2($image); 29 35 30 #see if files exist in content - we don't want to upload non-used selected files.36 // see if files exist in content - we don't want to upload non-used selected files. 31 37 preg_match('/'.$quoted.'/', $_REQUEST['content'], $matches[0]); 32 if($matches[0]) 33 $upload = media_sideload_image($data, $post_ID, $_REQUEST['photo_description'][$key]); 38 if($matches[0]) { 39 $upload = media_sideload_image($image, $post_ID, $_REQUEST['photo_description'][$key]); 40 // Replace the POSTED content <img> with correct uploaded ones. 41 if( !is_wp_error($upload) ) $content = preg_replace('/<img ([^>]*)src=(\"|\')'.$quoted.'(\2)([^>\/]*)\/*>/is', $upload, $content); 42 } 34 43 } 35 $content = $_REQUEST['content'];44 36 45 break; 37 46
