Ticket #6008: custom-header.diff
| File custom-header.diff, 2.7 KB (added by , 19 years ago) |
|---|
-
wp-admin/custom-header.php
211 211 die( $file['error'] ); 212 212 213 213 $url = $file['url']; 214 $type = $file['type']; 214 215 $file = $file['file']; 215 216 $filename = basename($file); 216 217 … … 218 219 $object = array( 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 224 225 // Save the data … … 227 228 list($width, $height, $type, $attr) = getimagesize( $file ); 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 232 236 return $this->finished(); … … 279 283 $_POST['height'] = $_POST['height'] * $_POST['oitar']; 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'] ); 284 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 290 285 291 $parent = get_post($_POST['attachment_id']); 286 287 292 $parent_url = $parent->guid; 293 $url = str_replace(basename($parent_url), basename($cropped), $parent_url); 288 294 289 $url = str_replace(basename($parent_url), basename($header), $parent_url); 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 ); 290 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 ) ); 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(); 300 316 }
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)