Ticket #17242: 17242.2.diff
File 17242.2.diff, 7.4 KB (added by , 9 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); … … 510 517 <th scope="row"><?php _e( 'Upload Image' ); ?></th> 511 518 <td> 512 519 <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> 520 <?php 521 $header_support = get_theme_support( 'custom-header' ); 522 if ( ! isset( $header_support[ 0 ] ) || empty( $header_support[ 0 ][ 'flex-height' ] ) || !$header_support[ 0 ][ 'flex-height' ] ) { 523 printf( __( 'Images of exactly <strong>%1$d × %2$d pixels</strong> will be used as-is.' ), HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT ); 524 } else { 525 printf( __( 'Images should be at least <strong>%1$d pixels</strong> wide.' ), HEADER_IMAGE_WIDTH ); 526 if ( !empty( $header_support[ 0 ][ 'suggested-height' ] ) ) 527 printf( __( ' Suggested height is <strong>%1$d pixels</strong>.' ), absint( $header_support[ 0 ][ 'suggested-height' ] ) ); 528 } 529 ?></p> 514 530 <form enctype="multipart/form-data" id="upload-form" method="post" action="<?php echo esc_attr( add_query_arg( 'step', 2 ) ) ?>"> 515 531 <p> 516 532 <label for="upload"><?php _e( 'Choose an image from your computer:' ); ?></label><br /> … … 662 678 663 679 list($width, $height, $type, $attr) = getimagesize( $file ); 664 680 665 if ( $width == HEADER_IMAGE_WIDTH && $height == HEADER_IMAGE_HEIGHT ) { 681 $header_support = get_theme_support( 'custom-header' ); 682 // If flexible height isn't supported and the image is the exact right size 683 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 684 // Add the meta-data 667 685 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); 668 686 update_post_meta( $id, '_wp_attachment_is_custom_header', get_option('stylesheet' ) ); … … 733 751 $attachment_id = absint( $_POST['attachment_id'] ); 734 752 $original = get_attached_file($attachment_id); 735 753 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 ); 754 $header_support = get_theme_support( 'custom-header' ); 755 if ( isset( $header_support[ 0 ] ) && !empty( $header_support[ 0 ][ 'flex-height' ] ) ) 756 $dst_height = (int) $_POST['height'] * ( HEADER_IMAGE_WIDTH / $_POST['width'] ); 757 else 758 $dst_height = HEADER_IMAGE_HEIGHT; 759 760 $cropped = wp_crop_image( $attachment_id, (int) $_POST['x1'], (int) $_POST['y1'], (int) $_POST['width'], (int) $_POST['height'], HEADER_IMAGE_WIDTH, $dst_height ); 737 761 if ( is_wp_error( $cropped ) ) 738 762 wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); 739 763 -
wp-includes/js/imgareaselect/jquery.imgareaselect.dev.js
1 1 /* 2 2 * imgAreaSelect jQuery plugin 3 * version 0.9. 63 * version 0.9.8 4 4 * 5 5 * Copyright (c) 2008-2011 Michal Wojciechowski (odyniec.net) 6 6 * … … 55 55 56 56 scaleX, scaleY, 57 57 58 resizeMargin = 10,59 60 58 resize, 61 59 62 60 minWidth, minHeight, maxWidth, maxHeight, … … 134 132 imgOfs.top += ($img.outerHeight() - imgHeight) >> 1; 135 133 imgOfs.left += ($img.outerWidth() - imgWidth) >> 1; 136 134 137 minWidth = options.minWidth|| 0;138 minHeight = options.minHeight|| 0;139 maxWidth = min(options.maxWidth || 1<<24, imgWidth);140 maxHeight = min(options.maxHeight || 1<<24, imgHeight);135 minWidth = round(options.minWidth / scaleX) || 0; 136 minHeight = round(options.minHeight / scaleY) || 0; 137 maxWidth = round(min(options.maxWidth / scaleX || 1<<24, imgWidth)); 138 maxHeight = round(min(options.maxHeight / scaleY || 1<<24, imgHeight)); 141 139 142 140 if ($().jquery == '1.3.2' && position == 'fixed' && 143 141 !docElem['getBoundingClientRect']) … … 146 144 imgOfs.left += max(document.body.scrollLeft, docElem.scrollLeft); 147 145 } 148 146 149 parOfs = $.inArray($parent.css('position'), ['absolute', 'relative']) + 1?147 parOfs = /absolute|relative/.test($parent.css('position')) ? 150 148 { left: round($parent.offset().left) - $parent.scrollLeft(), 151 149 top: round($parent.offset().top) - $parent.scrollTop() } : 152 150 position == 'fixed' ? … … 365 363 } 366 364 367 365 function selectingMouseMove(event) { 368 x2 = resize == '' || /w|e/.test(resize) || aspectRatio ? evX(event) : viewX(selection.x2);369 y2 = resize == '' || /n|s/.test(resize) || aspectRatio ? evY(event) : viewY(selection.y2);366 x2 = /w|e|^$/.test(resize) || aspectRatio ? evX(event) : viewX(selection.x2); 367 y2 = /n|s|^$/.test(resize) || aspectRatio ? evY(event) : viewY(selection.y2); 370 368 371 369 doResize(); 372 370 … … 408 406 409 407 resize = ''; 410 408 411 if ( $outer.is(':not(:visible)'))409 if (!$outer.is(':visible')) 412 410 $box.add($outer).hide().fadeIn(options.fadeSpeed||0); 413 411 414 412 shown = true; … … 427 425 428 426 setSelection(selX(x1), selY(y1), selX(x1), selY(y1)); 429 427 430 options.onSelectChange(img, getSelection()); 431 options.onSelectEnd(img, getSelection()); 428 if (!this instanceof $.imgAreaSelect) { 429 options.onSelectChange(img, getSelection()); 430 options.onSelectEnd(img, getSelection()); 431 } 432 432 } 433 433 434 434 function imgMouseDown(event) { … … 606 606 $box.append($area.add($border).add($areaOpera).add($handles)); 607 607 608 608 if ($.browser.msie) { 609 if (o = $outer.css('filter').match(/opacity=( [0-9]+)/))609 if (o = $outer.css('filter').match(/opacity=(\d+)/)) 610 610 $outer.css('opacity', o[1]/100); 611 if (o = $border.css('filter').match(/opacity=( [0-9]+)/))611 if (o = $border.css('filter').match(/opacity=(\d+)/)) 612 612 $border.css('opacity', o[1]/100); 613 613 } 614 614 … … 656 656 657 657 this.setSelection = setSelection; 658 658 659 this.cancelSelection = cancelSelection; 660 659 661 this.update = doUpdate; 660 662 661 663 $p = $img; … … 689 691 img.complete || img.readyState == 'complete' || !$img.is('img') ? 690 692 imgLoad() : $img.one('load', imgLoad); 691 693 692 if ($.browser.msie && $.browser.version >= 9)694 if ($.browser.msie && $.browser.version >= 7) 693 695 img.src = img.src; 694 696 }; 695 697