Make WordPress Core

Ticket #20657: 20657.6.patch

File 20657.6.patch, 2.0 KB (added by SergeyBiryukov, 12 years ago)
  • wp-admin/custom-header.php

     
    788788        <?php } ?>
    789789        <?php wp_nonce_field( 'custom-header-crop-image' ) ?>
    790790
    791         <?php submit_button( __( 'Crop and Publish' ) ); ?>
     791        <p class="submit"><?php
     792        submit_button( __( 'Crop and Publish' ), 'primary', 'submit', false );
     793        if ( isset( $oitar ) && 1 == $oitar )
     794                submit_button( __( 'Skip Cropping, Use Image as Is' ), 'primary', 'skip-cropping', false );
     795        ?>
    792796        </p>
    793797</form>
    794798</div>
     
    867871                else
    868872                        $dst_width = get_theme_support( 'custom-header', 'width' );
    869873
    870                 $cropped = wp_crop_image( $attachment_id, (int) $_POST['x1'], (int) $_POST['y1'], (int) $_POST['width'], (int) $_POST['height'], $dst_width, $dst_height );
    871                 if ( ! $cropped || is_wp_error( $cropped ) )
    872                         wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) );
     874                if ( !isset( $_POST['skip-cropping'] ) ) {
     875                        $cropped = wp_crop_image( $attachment_id, (int) $_POST['x1'], (int) $_POST['y1'], (int) $_POST['width'], (int) $_POST['height'], $dst_width, $dst_height );
     876                        if ( ! $cropped || is_wp_error( $cropped ) )
     877                                wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) );
     878                } else {
     879                        $cropped = get_attached_file( $attachment_id );
     880                }
    873881
    874882                $cropped = apply_filters('wp_create_file_in_uploads', $cropped, $attachment_id); // For replication
    875                 $is_cropped = ( get_attached_file( $attachment_id ) != $cropped );
     883                $is_cropped = ( !isset( $_POST['skip-cropping'] ) && ( get_attached_file( $attachment_id ) != $cropped ) );
    876884
    877885                $parent = get_post($attachment_id);
    878886                $parent_url = $parent->guid;
     
    890898                        'guid' => $url,
    891899                        'context' => 'custom-header'
    892900                );
    893                 if ( ! empty( $_POST['new-attachment'] ) )
     901                if ( ! empty( $_POST['new-attachment'] ) && $is_cropped )
    894902                        unset( $object['ID'] );
    895903
    896904                // Update the attachment