sorl-thumbnail icon indicating copy to clipboard operation
sorl-thumbnail copied to clipboard

using sorl-thumbnail and easy-thumbnails side-by-side

Open stefanfoulis opened this issue 8 years ago • 7 comments

It would be really useful to be able to use both easy-thumbnails and sorl-thumbnail in the same django project. 3rd-party apps may depend on one or the other and currently it is just impossible to install both into the same project.

As far as I can tell the only reason the two don't work together is because of variable name clashes.

Is this something both projects would consider addressing?

Problem: both libraries use the same names for things

In templates:

{% load thumbnail %}
{% thumbnail [...] %}

And in settings.py both use the same THUMBNAIL_ prefix:

THUMBNAIL_PREFIX = '...'

Suggested way to make both play nice together

My suggestion would be that both libraries switch to prefixing their settings uniquely:

SORL_THUMBNAIL_XXX
EASY_THUMBNAILS_XXX

For the transition both libraries could add a setting:

SORL_THUMBNAIL_NEW_SETTINGS_PREFIX = False
EASY_THUMBNAILS_NEW_SETTINGS_PREFIX = False

That reads the settings with the new prefix and outputs a deprecation warning if not set to True. After a few releases the default could be set to True.

Similarly for the templatetags. Both libraries could change the templatetags to use the prefix:

{% load easy_thumbnails_tags solr_thumbnail_tags %}

{% sorl_thumbnail [...] %}
{% easy_thumbnail [...] %}

Both libraries would keep the thumbnails version around, but it would issue a deprecation warning. If both are installed in the same project, the one first in INSTALLED_APPS would be used when using the old name.

stefanfoulis avatar Feb 25 '16 14:02 stefanfoulis

@mariocesar If we were to provide a PR for such a change, would you merge it?

stefanfoulis avatar Feb 10 '17 14:02 stefanfoulis

@stefanfoulis Sure

mariocesar avatar Feb 10 '17 15:02 mariocesar

Either, will be good to have an SORL_THUMBNAIL_TEMPLATETAG_NAME="thumbnail", though I will really see as beneficial to avoid a backward problem.

mariocesar avatar Feb 10 '17 15:02 mariocesar

👍

JordanReiter avatar Mar 06 '17 21:03 JordanReiter

For anyone coming across this post, this works for me in the meantime: https://stackoverflow.com/a/35166302/396300 with the caveat that you can only use one library on a particular template.

timmyomahony avatar Sep 02 '17 13:09 timmyomahony

Thanks to this file https://github.com/jazzband/sorl-thumbnail/blob/master/sorl/thumbnail/templatetags/sorl_thumbnail.py , it is now possible to use {% load sorl_thumbnail %} instead of {% load thumbnail %}.

I don't think the remaining conflicts have been fixed, though.

Flimm avatar Jul 20 '18 16:07 Flimm

easy-thumbnails now also provides alias {% load easy_thumbnails_tags %} , which solves the conflict on the other side too. I believe this ticket can be closed now.

yedpodtrzitko avatar Apr 27 '21 11:04 yedpodtrzitko