SmileyChris / easy-thumbnails

Easy thumbnails for Django
http://easy-thumbnails.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
1.37k stars 312 forks source link

Drop support for high resolution thumbnails #550

Open jrief opened 3 years ago

jrief commented 3 years ago

In 2014, when Retina displays where a new thing and the W3C did not provide any standardized method to handle images on displays with a pixel ratio of more than one, we had to fall back to a sort of hack, in order to render high resolution images. This included a JavaScript snippet looking for an image in high resolution, and if available serving that.

Fortunately HTML and CSS have evolved and this hack isn't required anymore. Instead we can use the srcset and sizes attributes inside our <img ...>. Other solutions are available though the <picture>-element and CSS media-queries.

I therefore will remove support for the configuration directives THUMBNAIL_HIGH_RESOLUTION and THUMBNAIL_HIGHRES_INFIX, since creating thumbnails can be handled with the means provided by the browsers themselves. For this purpose, I often use this Django snippet in my templates:

{% load thumbnail %}
{% thumbnail sample_image 150x100 crop as thumb %}
{% thumbnail sample_image 300x200 crop as thumb2 %}
<img src="{{ thumb.url }}" width="{{ thumb.width }}" height="{{ thumb.height }}" srcset="{{ thumb.url }} 1x, {{ thumb2.url }} 2x" />

This solution is faster than the retina.js-Hack and more importantly, it follows the HTML standard.

Are the any objections for removing this legacy code, which I added in 2014?