Changeset 7049
- Timestamp:
- 02/26/2008 09:07:15 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/custom-header.php
r6943 r7049 212 212 213 213 $url = $file['url']; 214 $type = $file['type']; 214 215 $file = $file['file']; 215 216 $filename = basename($file); … … 219 220 'post_title' => $filename, 220 221 'post_content' => $url, 221 'post_mime_type' => 'import',222 'post_mime_type' => $type, 222 223 'guid' => $url); 223 224 … … 228 229 229 230 if ( $width == HEADER_IMAGE_WIDTH && $height == HEADER_IMAGE_HEIGHT ) { 231 // Add the meta-data 232 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); 233 230 234 set_theme_mod('header_image', clean_url($url)); 231 235 do_action('wp_create_file_in_uploads', $file, $id); // For replication … … 280 284 } 281 285 282 $header = wp_crop_image($_POST['attachment_id'], $_POST['x1'], $_POST['y1'], $_POST['width'], $_POST['height'], HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT); 283 $header = apply_filters('wp_create_file_in_uploads', $header); // For replication 286 $original = get_attached_file( $_POST['attachment_id'] ); 287 288 $cropped = wp_crop_image($_POST['attachment_id'], $_POST['x1'], $_POST['y1'], $_POST['width'], $_POST['height'], HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT); 289 $cropped = apply_filters('wp_create_file_in_uploads', $cropped, $_POST['attachment_id']); // For replication 284 290 285 291 $parent = get_post($_POST['attachment_id']); 286 287 292 $parent_url = $parent->guid; 288 289 $url = str_replace(basename($parent_url), basename($header), $parent_url); 293 $url = str_replace(basename($parent_url), basename($cropped), $parent_url); 294 295 // Construct the object array 296 $object = array( 297 'ID' => $_POST['attachment_id'], 298 'post_title' => basename($cropped), 299 'post_content' => $url, 300 'post_mime_type' => 'image/jpeg', 301 'guid' => $url 302 ); 303 304 // Update the attachment 305 wp_insert_attachment($object, $cropped); 306 wp_update_attachment_metadata( $_POST['attachment_id'], wp_generate_attachment_metadata( $_POST['attachment_id'], $cropped ) ); 290 307 291 308 set_theme_mod('header_image', $url); 292 309 293 310 // cleanup 294 $file = get_attached_file( $_POST['attachment_id'] ); 295 $medium = str_replace(basename($file), 'midsize-'.basename($file), $file); 311 $medium = str_replace(basename($original), 'midsize-'.basename($original), $original); 296 312 @unlink( apply_filters( 'wp_delete_file', $medium ) ); 297 wp_delete_attachment( $_POST['attachment_id']);313 @unlink( apply_filters( 'wp_delete_file', $original ) ); 298 314 299 315 return $this->finished();
Note: See TracChangeset
for help on using the changeset viewer.