Make WordPress Core


Ignore:
Timestamp:
03/29/2014 08:50:57 AM (11 years ago)
Author:
nacin
Message:

Restyle the image editor so it looks way less hideous.

props avryl.
see #27544.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/image-edit.php

    r27712 r27842  
    3535    ?>
    3636    <div class="imgedit-wrap">
    37     <?php echo $note; ?>
    38     <table id="imgedit-panel-<?php echo $post_id; ?>"><tbody>
    39     <tr><td>
    40     <div class="imgedit-menu">
    41         <div onclick="imageEdit.crop(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-crop disabled" title="<?php esc_attr_e( 'Crop' ); ?>"></div><?php
    42 
    43     // On some setups GD library does not provide imagerotate() - Ticket #11536
    44     if ( wp_image_editor_supports( array( 'mime_type' => get_post_mime_type( $post_id ), 'methods' => array( 'rotate' ) ) ) ) { ?>
    45         <div class="imgedit-rleft"  onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)" title="<?php esc_attr_e( 'Rotate counter-clockwise' ); ?>"></div>
    46         <div class="imgedit-rright" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)" title="<?php esc_attr_e( 'Rotate clockwise' ); ?>"></div>
    47 <?php } else {
    48         $note_no_rotate = esc_attr__('Image rotation is not supported by your web host.');
    49 ?>
    50         <div class="imgedit-rleft disabled"  title="<?php echo $note_no_rotate; ?>"></div>
    51         <div class="imgedit-rright disabled" title="<?php echo $note_no_rotate; ?>"></div>
    52 <?php } ?>
    53 
    54         <div onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv" title="<?php esc_attr_e( 'Flip vertically' ); ?>"></div>
    55         <div onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-fliph" title="<?php esc_attr_e( 'Flip horizontally' ); ?>"></div>
    56 
    57         <div id="image-undo-<?php echo $post_id; ?>" onclick="imageEdit.undo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-undo disabled" title="<?php esc_attr_e( 'Undo' ); ?>"></div>
    58         <div id="image-redo-<?php echo $post_id; ?>" onclick="imageEdit.redo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-redo disabled" title="<?php esc_attr_e( 'Redo' ); ?>"></div>
    59         <br class="clear" />
    60     </div>
    61 
    62     <input type="hidden" id="imgedit-sizer-<?php echo $post_id; ?>" value="<?php echo $sizer; ?>" />
    63     <input type="hidden" id="imgedit-minthumb-<?php echo $post_id; ?>" value="<?php echo ( get_option('thumbnail_size_w') . ':' . get_option('thumbnail_size_h') ); ?>" />
    64     <input type="hidden" id="imgedit-history-<?php echo $post_id; ?>" value="" />
    65     <input type="hidden" id="imgedit-undone-<?php echo $post_id; ?>" value="0" />
    66     <input type="hidden" id="imgedit-selection-<?php echo $post_id; ?>" value="" />
    67     <input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" />
    68     <input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" />
    69 
    70     <div id="imgedit-crop-<?php echo $post_id; ?>" class="imgedit-crop-wrap">
    71     <img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')" src="<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>?action=imgedit-preview&amp;_ajax_nonce=<?php echo $nonce; ?>&amp;postid=<?php echo $post_id; ?>&amp;rand=<?php echo rand(1, 99999); ?>" />
    72     </div>
    73 
    74     <div class="imgedit-submit">
    75         <input type="button" onclick="imageEdit.close(<?php echo $post_id; ?>, 1)" class="button" value="<?php esc_attr_e( 'Cancel' ); ?>" />
    76         <input type="button" onclick="imageEdit.save(<?php echo "$post_id, '$nonce'"; ?>)" disabled="disabled" class="button-primary imgedit-submit-btn" value="<?php esc_attr_e( 'Save' ); ?>" />
    77     </div>
    78     </td>
    79 
    80     <td class="imgedit-settings">
     37    <div id="imgedit-panel-<?php echo $post_id; ?>">
     38
     39    <div class="imgedit-settings">
    8140    <div class="imgedit-group">
    8241    <div class="imgedit-group-top">
    83         <a class="imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" href="#"><strong><?php _e('Scale Image'); ?></strong></a>
     42        <h3><?php _e( 'Scale Image' ); ?> <a href="#" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;"></a></h3>
    8443        <div class="imgedit-help">
    8544        <p><?php _e('You can proportionally scale the original image. For best results the scaling should be done before performing any other operations on it like crop, rotate, etc. Note that images can only be scaled down, not up.'); ?></p>
     45        </div>
    8646        <?php if ( isset( $meta['width'], $meta['height'] ) ): ?>
    87         <p><?php printf( __('Original dimensions %s'), $meta['width'] . '&times;' . $meta['height'] ); ?></p>
     47        <p><?php printf( __('Original dimensions %s'), $meta['width'] . ' &times; ' . $meta['height'] ); ?></p>
    8848        <?php endif ?>
    8949        <div class="imgedit-submit">
    90         <span class="nowrap"><input type="text" id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" style="width:4em;" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" />&times;<input type="text" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" style="width:4em;" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" />
     50        <span class="nowrap"><input type="text" id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" style="width:4em;" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" /> &times; <input type="text" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" style="width:4em;" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" />
    9151        <span class="imgedit-scale-warn" id="imgedit-scale-warn-<?php echo $post_id; ?>">!</span></span>
    92         <input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'scale')" class="button-primary" value="<?php esc_attr_e( 'Scale' ); ?>" />
     52        <input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'scale')" class="button button-primary" value="<?php esc_attr_e( 'Scale' ); ?>" />
     53        </div>
     54    </div>
     55    </div>
     56
     57<?php if ( $can_restore ) { ?>
     58
     59    <div class="imgedit-group">
     60    <div class="imgedit-group-top">
     61        <h3><a onclick="imageEdit.toggleHelp(this);return false;" href="#"><?php _e('Restore Original Image'); ?> <span class="dashicons dashicons-arrow-down imgedit-help-toggle"></span></a></h3>
     62        <div class="imgedit-help">
     63        <p><?php _e('Discard any changes and restore the original image.');
     64
     65        if ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE )
     66            echo ' '.__('Previously edited copies of the image will not be deleted.');
     67
     68        ?></p>
     69        <div class="imgedit-submit">
     70        <input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'restore')" class="button button-primary" value="<?php esc_attr_e( 'Restore image' ); ?>" <?php echo $can_restore; ?> />
    9371        </div>
    9472        </div>
    9573    </div>
    96 
    97 <?php if ( $can_restore ) { ?>
    98 
    99     <div class="imgedit-group-top">
    100         <a class="imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" href="#"><strong><?php _e('Restore Original Image'); ?></strong></a>
    101         <div class="imgedit-help">
    102         <p><?php _e('Discard any changes and restore the original image.');
    103 
    104         if ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE )
    105             echo ' '.__('Previously edited copies of the image will not be deleted.');
    106 
    107         ?></p>
    108         <div class="imgedit-submit">
    109         <input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'restore')" class="button-primary" value="<?php esc_attr_e( 'Restore image' ); ?>" <?php echo $can_restore; ?> />
    110         </div>
    111         </div>
    11274    </div>
    11375
    11476<?php } ?>
    115 
    116     </div>
    11777
    11878    <div class="imgedit-group">
    11979    <div class="imgedit-group-top">
    120         <strong><?php _e('Image Crop'); ?></strong>
    121         <a class="imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" href="#"><?php _e('(help)'); ?></a>
     80        <h3><?php _e('Image Crop'); ?> <a href="#" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;"></a></h3>
     81
    12282        <div class="imgedit-help">
    12383        <p><?php _e('The image can be cropped by clicking on it and dragging to select the desired part. While dragging the dimensions of the selection are displayed below.'); ?></p>
     
    156116    <div class="imgedit-group imgedit-applyto">
    157117    <div class="imgedit-group-top">
    158         <strong><?php _e('Thumbnail Settings'); ?></strong>
    159         <a class="imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" href="#"><?php _e('(help)'); ?></a>
     118        <h3><?php _e('Thumbnail Settings'); ?> <a href="#" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;"></a></h3>
    160119        <p class="imgedit-help"><?php _e('The thumbnail image can be cropped differently. For example it can be square or contain only a portion of the original image to showcase it better. Here you can select whether to apply changes to all image sizes or make the thumbnail different.'); ?></p>
    161120    </div>
     
    185144    <?php } ?>
    186145
    187     </td></tr>
    188     </tbody></table>
     146    </div>
     147   
     148    <div class="imgedit-panel-content">
     149        <?php echo $note; ?>
     150        <div class="imgedit-menu">
     151            <div onclick="imageEdit.crop(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-crop disabled" title="<?php esc_attr_e( 'Crop' ); ?>"></div><?php
     152   
     153        // On some setups GD library does not provide imagerotate() - Ticket #11536
     154        if ( wp_image_editor_supports( array( 'mime_type' => get_post_mime_type( $post_id ), 'methods' => array( 'rotate' ) ) ) ) { ?>
     155            <div class="imgedit-rleft"  onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)" title="<?php esc_attr_e( 'Rotate counter-clockwise' ); ?>"></div>
     156            <div class="imgedit-rright" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)" title="<?php esc_attr_e( 'Rotate clockwise' ); ?>"></div>
     157    <?php } else {
     158            $note_no_rotate = esc_attr__('Image rotation is not supported by your web host.');
     159    ?>
     160            <div class="imgedit-rleft disabled"  title="<?php echo $note_no_rotate; ?>"></div>
     161            <div class="imgedit-rright disabled" title="<?php echo $note_no_rotate; ?>"></div>
     162    <?php } ?>
     163   
     164            <div onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv" title="<?php esc_attr_e( 'Flip vertically' ); ?>"></div>
     165            <div onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-fliph" title="<?php esc_attr_e( 'Flip horizontally' ); ?>"></div>
     166   
     167            <div id="image-undo-<?php echo $post_id; ?>" onclick="imageEdit.undo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-undo disabled" title="<?php esc_attr_e( 'Undo' ); ?>"></div>
     168            <div id="image-redo-<?php echo $post_id; ?>" onclick="imageEdit.redo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-redo disabled" title="<?php esc_attr_e( 'Redo' ); ?>"></div>
     169            <br class="clear" />
     170        </div>
     171   
     172        <input type="hidden" id="imgedit-sizer-<?php echo $post_id; ?>" value="<?php echo $sizer; ?>" />
     173        <input type="hidden" id="imgedit-minthumb-<?php echo $post_id; ?>" value="<?php echo ( get_option('thumbnail_size_w') . ':' . get_option('thumbnail_size_h') ); ?>" />
     174        <input type="hidden" id="imgedit-history-<?php echo $post_id; ?>" value="" />
     175        <input type="hidden" id="imgedit-undone-<?php echo $post_id; ?>" value="0" />
     176        <input type="hidden" id="imgedit-selection-<?php echo $post_id; ?>" value="" />
     177        <input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" />
     178        <input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" />
     179   
     180        <div id="imgedit-crop-<?php echo $post_id; ?>" class="imgedit-crop-wrap">
     181        <img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')" src="<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>?action=imgedit-preview&amp;_ajax_nonce=<?php echo $nonce; ?>&amp;postid=<?php echo $post_id; ?>&amp;rand=<?php echo rand(1, 99999); ?>" />
     182        </div>
     183   
     184        <div class="imgedit-submit">
     185            <input type="button" onclick="imageEdit.close(<?php echo $post_id; ?>, 1)" class="button" value="<?php esc_attr_e( 'Cancel' ); ?>" />
     186            <input type="button" onclick="imageEdit.save(<?php echo "$post_id, '$nonce'"; ?>)" disabled="disabled" class="button button-primary imgedit-submit-btn" value="<?php esc_attr_e( 'Save' ); ?>" />
     187        </div>
     188    </div>
     189   
     190    </div>
    189191    <div class="imgedit-wait" id="imgedit-wait-<?php echo $post_id; ?>"></div>
    190192    <script type="text/javascript">jQuery( function() { imageEdit.init(<?php echo $post_id; ?>); });</script>
Note: See TracChangeset for help on using the changeset viewer.