From 575dc2fa8150a7e459ad3edc2d311a49481a9ba6 Mon Sep 17 00:00:00 2001 From: Dave Cranwell Date: Tue, 13 Oct 2015 17:32:30 +0100 Subject: [PATCH] Removing need for an image rendition required by wagtail out the box, by reusing and shrinking another. --- .../wagtailadmin/scss/components/forms.scss | 15 +++++++++++++-- .../wagtailimages/widgets/image_chooser.html | 2 +- wagtail/wagtailimages/views/chooser.py | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/wagtail/wagtailadmin/static_src/wagtailadmin/scss/components/forms.scss b/wagtail/wagtailadmin/static_src/wagtailadmin/scss/components/forms.scss index 8b7288b7d3..a0ce36edc7 100644 --- a/wagtail/wagtailadmin/static_src/wagtailadmin/scss/components/forms.scss +++ b/wagtail/wagtailadmin/static_src/wagtailadmin/scss/components/forms.scss @@ -871,8 +871,19 @@ ul.inline li:first-child, li.inline:first-child{ } .preview-image{ float:left; - margin-left:-($thumbnail-width); - margin-right:1em; + margin-left: -($thumbnail-width); + margin-right: 1em; + max-width: $thumbnail-width; + + // Resize standard Wagtail thumbnail size (165x165) to 130 for space-saving purposes. + // We could request a 130x130 rendition, but that's just unnecessary and burdens installations + // where images are store off-site with higher rendering times. + img{ + max-width: $thumbnail-width; + max-height: $thumbnail-width; + height: auto; + width: auto; + } } } } diff --git a/wagtail/wagtailimages/templates/wagtailimages/widgets/image_chooser.html b/wagtail/wagtailimages/templates/wagtailimages/widgets/image_chooser.html index fee541998a..8e8fc35b41 100644 --- a/wagtail/wagtailimages/templates/wagtailimages/widgets/image_chooser.html +++ b/wagtail/wagtailimages/templates/wagtailimages/widgets/image_chooser.html @@ -6,7 +6,7 @@ {% block chosen_state_view %}
{% if image %} - {% image image max-130x130 %} + {% image image max-165x165 %} {% else %} {% endif %} diff --git a/wagtail/wagtailimages/views/chooser.py b/wagtail/wagtailimages/views/chooser.py index 315c9e2933..57f9b1640c 100644 --- a/wagtail/wagtailimages/views/chooser.py +++ b/wagtail/wagtailimages/views/chooser.py @@ -19,7 +19,7 @@ def get_image_json(image): helper function: given an image, return the json to pass back to the image chooser panel """ - preview_image = image.get_rendition('max-130x100') + preview_image = image.get_rendition('max-165x165') return json.dumps({ 'id': image.id,