diff --git a/cmsplugin_filer_image/cms_plugins.py b/cmsplugin_filer_image/cms_plugins.py index 80c4b4be..fba85d70 100644 --- a/cmsplugin_filer_image/cms_plugins.py +++ b/cmsplugin_filer_image/cms_plugins.py @@ -33,6 +33,7 @@ class FilerImagePlugin(CMSPluginBase): ('width', 'height', 'crop', 'upscale'), 'thumbnail_option', 'use_autoscale', + 'use_hidpi_pair', ) }), (None, { @@ -107,11 +108,13 @@ def render(self, context, instance, placeholder): self.TEMPLATE_NAME % 'default') ) options = self._get_thumbnail_options(context, instance) + size = options.get('size', None) context.update({ 'instance': instance, 'link': instance.link, 'opts': options, - 'size': options.get('size', None), + 'size': size, + 'double_size': tuple(map(lambda x: x * 2, size )), 'placeholder': placeholder }) return context diff --git a/cmsplugin_filer_image/models.py b/cmsplugin_filer_image/models.py index bb623cb4..b1dc27f6 100644 --- a/cmsplugin_filer_image/models.py +++ b/cmsplugin_filer_image/models.py @@ -28,6 +28,8 @@ class FilerImage(CMSPlugin): alt_text = models.CharField(_("alt text"), null=True, blank=True, max_length=255) use_original_image = models.BooleanField(_("use the original image"), default=False, help_text=_('do not resize the image. use the original image instead.')) + use_hidpi_pair = models.BooleanField(_("create a pair of images for Retina/HiDPI."), + default=False) thumbnail_option = models.ForeignKey('ThumbnailOption', null=True, blank=True, verbose_name=_("thumbnail option"), help_text=_('overrides width, height, crop and upscale with values from the selected thumbnail option')) use_autoscale = models.BooleanField(_("use automatic scaling"), default=False, diff --git a/cmsplugin_filer_image/static/cmsplugin_filer_image/images/t.gif b/cmsplugin_filer_image/static/cmsplugin_filer_image/images/t.gif new file mode 100755 index 00000000..fc256098 Binary files /dev/null and b/cmsplugin_filer_image/static/cmsplugin_filer_image/images/t.gif differ diff --git a/cmsplugin_filer_image/templates/cmsplugin_filer_image/plugins/image/default.html b/cmsplugin_filer_image/templates/cmsplugin_filer_image/plugins/image/default.html index 4d5ecebb..7dad437a 100644 --- a/cmsplugin_filer_image/templates/cmsplugin_filer_image/plugins/image/default.html +++ b/cmsplugin_filer_image/templates/cmsplugin_filer_image/plugins/image/default.html @@ -1,4 +1,4 @@ -{% load thumbnail filer_tags filer_image_tags %}{% spaceless %} +{% load filer_tags filer_image_tags sekizai_tags staticfiles thumbnail %}{% spaceless %} {% comment %} You may change the image size for special cases in your project by overriding this template. There are a few size manipulation filters for this in @@ -14,7 +14,21 @@ {% if link %}{% endif %} {% if instance.image %} - {% if instance.use_original_image %} + {% if instance.use_hidpi_pair %} + {% thumbnail instance.image size crop=opts.crop upscale=opts.upscale subject_location=opts.subject_location as losrc %} + {% thumbnail instance.image double_size crop=opts.crop upscale=opts.upscale subject_location=opts.subject_location as hisrc %} + {% if instance.alt %}{{ instance.alt }}{% endif %} + {% addtoblock "js" %} + + {% endaddtoblock %} + {% elif instance.use_original_image %} {% if instance.alt %}{{ instance.alt }}{% endif %} {% else %} {% thumbnail instance.image size crop=opts.crop upscale=opts.upscale subject_location=opts.subject_location as thumbnail %}