Make WordPress Core

Ticket #21785: 21785-mm-crop-error-overlay.diff

File 21785-mm-crop-error-overlay.diff, 3.8 KB (added by ehg, 11 years ago)

overlay error on cropping fail

  • src/wp-admin/js/customize-controls.js

    diff --git src/wp-admin/js/customize-controls.js src/wp-admin/js/customize-controls.js
    index 39edc8b..88e020c 100644
     
    389389                                keys: true,
    390390                                instance: true,
    391391                                persistent: true,
    392                                 parent: this.$el,
    393392                                imageWidth: realWidth,
    394393                                imageHeight: realHeight,
    395394                                x1: 0,
  • src/wp-includes/css/media-views.css

    diff --git src/wp-includes/css/media-views.css src/wp-includes/css/media-views.css
    index cccf307..34687a8 100644
     
    608608        margin-right: 20px;
    609609}
    610610
    611 .media-frame-content .crop-content {
     611.media-frame-content .crop-content .crop-image {
    612612        display: block;
    613613        margin: auto;
    614614        max-width: 100%;
    615615        max-height: 100%;
    616616}
    617617
     618.media-frame-content .crop-content .upload-errors
     619{
     620        position: absolute;
     621        width: 300px;
     622        top: 50%;
     623        left: 50%;
     624        margin-left: -150px;
     625        margin-right: -150px;
     626        z-index: 600000;
     627}
     628
    618629/**
    619630 * Iframes
    620631 */
  • src/wp-includes/js/media-views.js

    diff --git src/wp-includes/js/media-views.js src/wp-includes/js/media-views.js
    index 80db8d2..a979343 100644
     
    13441344                                                        this.controller.state().doCrop( selection ).done( function( croppedImage ) {
    13451345                                                                self.controller.trigger('cropped', croppedImage );
    13461346                                                                self.controller.close();
     1347                                                        }).fail( function() {
     1348                                                                self.controller.trigger('content:error:crop');
    13471349                                                        });
    13481350                                                }
    13491351                                        }
     
    61636165         * @augments Backbone.View
    61646166         */
    61656167        media.view.Cropper = media.View.extend({
    6166                 tagName: 'img',
    61676168                className: 'crop-content',
     6169                template: media.template('crop-content'),
    61686170                initialize: function() {
    61696171                        _.bindAll(this, 'onImageLoad');
    6170                         this.$el.attr('src', this.options.attachment.get('url'));
    61716172                },
    61726173                ready: function() {
    6173                         this.$el.on('load', this.onImageLoad);
     6174                        this.controller.frame.on('content:error:crop', this.onError, this);
     6175                        this.$image = this.$el.find('.crop-image');
     6176                        this.$image.on('load', this.onImageLoad);
    61746177                        $(window).on('resize.cropper', _.debounce(this.onImageLoad, 250));
    61756178                },
    61766179                remove: function() {
     
    61906193                        if (typeof imgOptions === 'function') {
    61916194                                imgOptions = imgOptions(this.options.attachment, this.controller);
    61926195                        }
     6196
     6197                        imgOptions = _.extend(imgOptions, {parent: this.$el});
    61936198                        this.trigger('image-loaded');
    6194                         this.controller.imgSelect = this.$el.imgAreaSelect(imgOptions);
    6195                 }
     6199                        this.controller.imgSelect = this.$image.imgAreaSelect(imgOptions);
     6200                },
     6201                onError: function() {
     6202                        var filename = this.options.attachment.get('filename');
    61966203
     6204                        this.views.add( '.upload-errors', new media.view.UploaderStatusError({
     6205                                filename: media.view.UploaderStatus.prototype.filename(filename),
     6206                                message: _wpMediaViewsL10n.cropError
     6207                        }), { at: 0 });
     6208                }
    61976209        });
    61986210
    61996211        media.view.EditImage = media.View.extend({
  • src/wp-includes/media-template.php

    diff --git src/wp-includes/media-template.php src/wp-includes/media-template.php
    index 76e595c..c85a3e3 100644
    function wp_print_media_templates() { 
    10341034                <div class="wpview-overlay"></div>
    10351035        </script>
    10361036
     1037        <script type="text/html" id="tmpl-crop-content">
     1038                <img class="crop-image" src="{{ data.url }}">
     1039                <div class="upload-errors"></div>
     1040        </script>
     1041
    10371042        <?php
    10381043
    10391044        /**
  • src/wp-includes/media.php

    diff --git src/wp-includes/media.php src/wp-includes/media.php
    index ad2e7e6..64bf81d 100644
    function wp_enqueue_media( $args = array() ) { 
    25282528                'cropping' => __( 'Cropping&hellip;' ),
    25292529                'suggestedWidth' => __( 'Suggested width is %d pixels.' ),
    25302530                'suggestedHeight' => __( 'Suggested height is %d pixels.' ),
     2531                'cropError' => __( 'There has been an error cropping your image.' ),
    25312532
    25322533                // Edit Audio
    25332534                'audioDetailsTitle'     => __( 'Audio Details' ),