Ticket #17242: 17242.3.diff
File 17242.3.diff, 4.3 KB (added by , 11 years ago) |
---|
-
wp-admin/custom-header.php
438 438 jQuery('img#upload').imgAreaSelect({ 439 439 handles: true, 440 440 keys: true, 441 aspectRatio: xinit + ':' + yinit,442 441 show: true, 443 442 x1: 0, 444 443 y1: 0, 445 444 x2: xinit, 446 445 y2: yinit, 446 <?php 447 $header_support = get_theme_support( 'custom-header' ); 448 if ( ! isset( $header_support[ 0 ] ) || empty( $header_support[ 0 ][ 'flex-height' ] ) || !$header_support[ 0 ][ 'flex-height' ] ) { 449 ?> 450 aspectRatio: xinit + ':' + yinit, 447 451 maxHeight: <?php echo HEADER_IMAGE_HEIGHT; ?>, 452 <?php 453 } 454 ?> 448 455 maxWidth: <?php echo HEADER_IMAGE_WIDTH; ?>, 449 456 onInit: function () { 450 457 jQuery('#width').val(xinit); … … 492 499 call_user_func( $this->admin_image_div_callback ); 493 500 } else { 494 501 ?> 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() ) ?>);"> 502 <div id="headimg" style="max-width:<?php echo HEADER_IMAGE_WIDTH; ?>px;"> 503 <img src="<?php header_image(); ?>" /> 496 504 <?php 497 505 if ( 'blank' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) || '' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) || ! $this->header_text() ) 498 506 $style = ' style="display:none;"'; … … 510 518 <th scope="row"><?php _e( 'Upload Image' ); ?></th> 511 519 <td> 512 520 <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> 521 <?php 522 $header_support = get_theme_support( 'custom-header' ); 523 if ( ! isset( $header_support[ 0 ] ) || empty( $header_support[ 0 ][ 'flex-height' ] ) || !$header_support[ 0 ][ 'flex-height' ] ) { 524 printf( __( 'Images of exactly <strong>%1$d × %2$d pixels</strong> will be used as-is.' ), HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT ); 525 } else { 526 printf( __( 'Images should be at least <strong>%1$d pixels</strong> wide.' ), HEADER_IMAGE_WIDTH ); 527 if ( !empty( $header_support[ 0 ][ 'suggested-height' ] ) ) 528 printf( __( ' Suggested height is <strong>%1$d pixels</strong>.' ), absint( $header_support[ 0 ][ 'suggested-height' ] ) ); 529 } 530 ?></p> 514 531 <form enctype="multipart/form-data" id="upload-form" method="post" action="<?php echo esc_attr( add_query_arg( 'step', 2 ) ) ?>"> 515 532 <p> 516 533 <label for="upload"><?php _e( 'Choose an image from your computer:' ); ?></label><br /> … … 662 679 663 680 list($width, $height, $type, $attr) = getimagesize( $file ); 664 681 665 if ( $width == HEADER_IMAGE_WIDTH && $height == HEADER_IMAGE_HEIGHT ) { 682 $header_support = get_theme_support( 'custom-header' ); 683 // If flexible height isn't supported and the image is the exact right size 684 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 685 // Add the meta-data 667 686 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); 668 687 update_post_meta( $id, '_wp_attachment_is_custom_header', get_option('stylesheet' ) ); … … 733 752 $attachment_id = absint( $_POST['attachment_id'] ); 734 753 $original = get_attached_file($attachment_id); 735 754 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 ); 755 $header_support = get_theme_support( 'custom-header' ); 756 if ( isset( $header_support[ 0 ] ) && !empty( $header_support[ 0 ][ 'flex-height' ] ) ) 757 $dst_height = (int) $_POST['height'] * ( HEADER_IMAGE_WIDTH / $_POST['width'] ); 758 else 759 $dst_height = HEADER_IMAGE_HEIGHT; 760 761 $cropped = wp_crop_image( $attachment_id, (int) $_POST['x1'], (int) $_POST['y1'], (int) $_POST['width'], (int) $_POST['height'], HEADER_IMAGE_WIDTH, $dst_height ); 737 762 if ( is_wp_error( $cropped ) ) 738 763 wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); 739 764