Ticket #17242: 17242.6.diff
File 17242.6.diff, 6.8 KB (added by , 11 years ago) |
---|
-
wp-includes/theme.php
1547 1547 1548 1548 foreach ( (array) $headers as $header ) { 1549 1549 $url = esc_url_raw( $header->guid ); 1550 $header_data = wp_get_attachment_metadata( $header->ID ); 1550 1551 $header = basename($url); 1551 1552 $header_images[$header] = array(); 1552 1553 $header_images[$header]['url'] = $url; 1553 1554 $header_images[$header]['thumbnail_url'] = $url; 1554 1555 $header_images[$header]['uploaded'] = true; 1556 $header_images[$header]['width'] = $header_data['width']; 1557 $header_images[$header]['height'] = $header_data['height']; 1555 1558 } 1556 1559 1557 1560 return $header_images; 1558 1561 } 1559 1562 1563 function get_header_image_width() { 1564 return get_theme_mod( 'header_image_width', HEADER_IMAGE_WIDTH ); 1565 } 1566 1567 function get_header_image_height() { 1568 return get_theme_mod( 'header_image_height', HEADER_IMAGE_HEIGHT ); 1569 } 1570 1560 1571 /** 1561 1572 * Add callbacks for image header display. 1562 1573 * -
wp-admin/custom-header.php
225 225 } else { 226 226 $this->process_default_headers(); 227 227 $uploaded = get_uploaded_header_images(); 228 if ( isset( $uploaded[$_POST['default-header']] ) ) 228 if ( isset( $uploaded[$_POST['default-header']] ) ) { 229 229 set_theme_mod( 'header_image', esc_url( $uploaded[$_POST['default-header']]['url'] ) ); 230 elseif ( isset( $this->default_headers[$_POST['default-header']] ) ) 230 set_theme_mod( 'header_image_width', $uploaded[$_POST['default-header']]['width'] ); 231 set_theme_mod( 'header_image_height', $uploaded[$_POST['default-header']]['height'] ); 232 } elseif ( isset( $this->default_headers[$_POST['default-header']] ) ) { 231 233 set_theme_mod( 'header_image', esc_url( $this->default_headers[$_POST['default-header']]['url'] ) ); 234 $width = empty( $this->default_headers[$_POST['default-header']]['width'] )? HEADER_IMAGE_WIDTH : $this->default_headers[$_POST['default-header']]['width']; 235 $height = empty( $this->default_headers[$_POST['default-header']]['height'] )? HEADER_IMAGE_HEIGHT : $this->default_headers[$_POST['default-header']]['height']; 236 set_theme_mod( 'header_image_width', $width ); 237 set_theme_mod( 'header_image_height', $height ); 238 } 232 239 } 233 240 } 234 241 } … … 438 445 jQuery('img#upload').imgAreaSelect({ 439 446 handles: true, 440 447 keys: true, 441 aspectRatio: xinit + ':' + yinit,442 448 show: true, 443 449 x1: 0, 444 450 y1: 0, 445 451 x2: xinit, 446 452 y2: yinit, 453 <?php 454 $header_support = get_theme_support( 'custom-header' ); 455 if ( ! isset( $header_support[ 0 ] ) || empty( $header_support[ 0 ][ 'flex-height' ] ) || !$header_support[ 0 ][ 'flex-height' ] ) { 456 ?> 457 aspectRatio: xinit + ':' + yinit, 447 458 maxHeight: <?php echo HEADER_IMAGE_HEIGHT; ?>, 459 <?php 460 } 461 ?> 448 462 maxWidth: <?php echo HEADER_IMAGE_WIDTH; ?>, 449 463 onInit: function () { 450 464 jQuery('#width').val(xinit); … … 492 506 call_user_func( $this->admin_image_div_callback ); 493 507 } else { 494 508 ?> 495 <div id="headimg" style="max-width:<?php echo HEADER_IMAGE_WIDTH; ?>px;height:<?php echo HEADER_IMAGE_HEIGHT; ?>px;background-image:url(<?php esc_url ( header_image() ) ?>);">509 <div id="headimg" style="max-width:<?php echo get_header_image_width(); ?>px;height:<?php echo get_header_image_height(); ?>px;background-image:url(<?php esc_url ( header_image() ) ?>);"> 496 510 <?php 497 511 if ( 'blank' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) || '' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) || ! $this->header_text() ) 498 512 $style = ' style="display:none;"'; … … 510 524 <th scope="row"><?php _e( 'Upload Image' ); ?></th> 511 525 <td> 512 526 <p><?php _e( 'You can upload a custom header image to be shown at the top of your site instead of the default one. On the next screen you will be able to crop the image.' ); ?><br /> 513 <?php printf( __( 'Images of exactly <strong>%1$d × %2$d pixels</strong> will be used as-is.' ), HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT ); ?></p> 527 <?php 528 $header_support = get_theme_support( 'custom-header' ); 529 if ( ! isset( $header_support[ 0 ] ) || empty( $header_support[ 0 ][ 'flex-height' ] ) || !$header_support[ 0 ][ 'flex-height' ] ) { 530 printf( __( 'Images of exactly <strong>%1$d × %2$d pixels</strong> will be used as-is.' ), HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT ); 531 } else { 532 printf( __( 'Images should be at least <strong>%1$d pixels</strong> wide.' ), HEADER_IMAGE_WIDTH ); 533 if ( !empty( $header_support[ 0 ][ 'suggested-height' ] ) ) 534 printf( __( ' Suggested height is <strong>%1$d pixels</strong>.' ), absint( $header_support[ 0 ][ 'suggested-height' ] ) ); 535 } 536 ?></p> 514 537 <form enctype="multipart/form-data" id="upload-form" method="post" action="<?php echo esc_attr( add_query_arg( 'step', 2 ) ) ?>"> 515 538 <p> 516 539 <label for="upload"><?php _e( 'Choose an image from your computer:' ); ?></label><br /> … … 662 685 663 686 list($width, $height, $type, $attr) = getimagesize( $file ); 664 687 665 if ( $width == HEADER_IMAGE_WIDTH && $height == HEADER_IMAGE_HEIGHT ) { 688 $header_support = get_theme_support( 'custom-header' ); 689 // If flexible height isn't supported and the image is the exact right size 690 if ( ( !isset( $header_support[ 0 ] ) || empty( $header_support[ 0 ][ 'flex-height' ] ) || !empty( $header_support[ 0 ][ 'flex-height' ] ) ) && $width == HEADER_IMAGE_WIDTH && $height == HEADER_IMAGE_HEIGHT ) { 666 691 // Add the meta-data 667 692 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); 668 693 update_post_meta( $id, '_wp_attachment_is_custom_header', get_option('stylesheet' ) ); … … 733 758 $attachment_id = absint( $_POST['attachment_id'] ); 734 759 $original = get_attached_file($attachment_id); 735 760 736 $cropped = wp_crop_image( $attachment_id, (int) $_POST['x1'], (int) $_POST['y1'], (int) $_POST['width'], (int) $_POST['height'], HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT ); 761 $header_support = get_theme_support( 'custom-header' ); 762 if ( isset( $header_support[ 0 ] ) && !empty( $header_support[ 0 ][ 'flex-height' ] ) ) 763 $dst_height = (int) $_POST['height'] * ( HEADER_IMAGE_WIDTH / $_POST['width'] ); 764 else 765 $dst_height = HEADER_IMAGE_HEIGHT; 766 767 $cropped = wp_crop_image( $attachment_id, (int) $_POST['x1'], (int) $_POST['y1'], (int) $_POST['width'], (int) $_POST['height'], HEADER_IMAGE_WIDTH, $dst_height ); 737 768 if ( is_wp_error( $cropped ) ) 738 769 wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); 739 770 -
wp-admin/css/wp-admin.dev.css
4494 4494 4495 4495 .appearance_page_custom-header #headimg { 4496 4496 border: 1px solid #DFDFDF; 4497 min-height: 100px;4498 4497 width: 100%; 4499 4498 } 4500 4499