Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for high resolution thumbnails #550

Open
jrief opened this issue Sep 6, 2020 · 0 comments
Open

Drop support for high resolution thumbnails #550

jrief opened this issue Sep 6, 2020 · 0 comments
Assignees

Comments

@jrief
Copy link
Collaborator

jrief commented Sep 6, 2020

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant