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

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

Open
stefanfoulis opened this issue Feb 25, 2016 · 7 comments
Open

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

stefanfoulis opened this issue Feb 25, 2016 · 7 comments

Comments

@stefanfoulis
Copy link

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
Copy link
Author

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

@mariocesar
Copy link
Collaborator

@stefanfoulis Sure

@mariocesar
Copy link
Collaborator

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

@JordanReiter
Copy link

JordanReiter commented Mar 6, 2017

👍

@timmyomahony
Copy link

timmyomahony commented Sep 2, 2017

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.

@Flimm
Copy link
Contributor

Flimm commented Jul 20, 2018

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.

@yedpodtrzitko
Copy link

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.

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

6 participants