Make WordPress Core

Changeset 27946


Ignore:
Timestamp:
04/04/2014 03:47:43 PM (12 years ago)
Author:
nacin
Message:

Header images: Handle cropping failures.

props ehg.
see #21785.

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/customize-controls.js

    r27757 r27946  
    390390                                instance: true,
    391391                                persistent: true,
    392                                 parent: this.$el,
    393392                                imageWidth: realWidth,
    394393                                imageHeight: realHeight,
  • trunk/src/wp-includes/css/media-views.css

    r27918 r27946  
    610610}
    611611
    612 .media-frame-content .crop-content {
     612.media-frame-content .crop-content .crop-image {
    613613        display: block;
    614614        margin: auto;
    615615        max-width: 100%;
    616616        max-height: 100%;
     617}
     618
     619.media-frame-content .crop-content .upload-errors
     620{
     621        position: absolute;
     622        width: 300px;
     623        top: 50%;
     624        left: 50%;
     625        margin-left: -150px;
     626        margin-right: -150px;
     627        z-index: 600000;
    617628}
    618629
  • trunk/src/wp-includes/js/media-views.js

    r27942 r27946  
    13451345                                                                self.controller.trigger('cropped', croppedImage );
    13461346                                                                self.controller.close();
     1347                                                        }).fail( function() {
     1348                                                                self.controller.trigger('content:error:crop');
    13471349                                                        });
    13481350                                                }
     
    62036205         */
    62046206        media.view.Cropper = media.View.extend({
    6205                 tagName: 'img',
    62066207                className: 'crop-content',
     6208                template: media.template('crop-content'),
    62076209                initialize: function() {
    62086210                        _.bindAll(this, 'onImageLoad');
    6209                         this.$el.attr('src', this.options.attachment.get('url'));
    62106211                },
    62116212                ready: function() {
    6212                         this.$el.on('load', this.onImageLoad);
     6213                        this.controller.frame.on('content:error:crop', this.onError, this);
     6214                        this.$image = this.$el.find('.crop-image');
     6215                        this.$image.on('load', this.onImageLoad);
    62136216                        $(window).on('resize.cropper', _.debounce(this.onImageLoad, 250));
    62146217                },
     
    62306233                                imgOptions = imgOptions(this.options.attachment, this.controller);
    62316234                        }
     6235
     6236                        imgOptions = _.extend(imgOptions, {parent: this.$el});
    62326237                        this.trigger('image-loaded');
    6233                         this.controller.imgSelect = this.$el.imgAreaSelect(imgOptions);
     6238                        this.controller.imgSelect = this.$image.imgAreaSelect(imgOptions);
     6239                },
     6240                onError: function() {
     6241                        var filename = this.options.attachment.get('filename');
     6242
     6243                        this.views.add( '.upload-errors', new media.view.UploaderStatusError({
     6244                                filename: media.view.UploaderStatus.prototype.filename(filename),
     6245                                message: _wpMediaViewsL10n.cropError
     6246                        }), { at: 0 });
    62346247                }
    6235 
    62366248        });
    62376249
  • trunk/src/wp-includes/media-template.php

    r27918 r27946  
    10491049        </script>
    10501050
     1051        <script type="text/html" id="tmpl-crop-content">
     1052                <img class="crop-image" src="{{ data.url }}">
     1053                <div class="upload-errors"></div>
     1054        </script>
     1055
    10511056        <?php
    10521057
  • trunk/src/wp-includes/media.php

    r27914 r27946  
    25302530                'suggestedWidth' => __( 'Suggested width is %d pixels.' ),
    25312531                'suggestedHeight' => __( 'Suggested height is %d pixels.' ),
     2532                'cropError' => __( 'There has been an error cropping your image.' ),
    25322533
    25332534                // Edit Audio
Note: See TracChangeset for help on using the changeset viewer.