Closed fgmacedo closed 8 years ago
@anrie @jonasvp Hi! Sorry for this direct message. I've received a positive feedback from the developer of django-filebrowser
and my pull-request is getting close to be merged.
But to get the integration working, I will need the changes of this PR into django-image-cropping
. Do you have any feedback? Is there something that I can do?
Best regards,
Hey Fernando,
sorry for the late response and thanks for your PR!
Concerning your proposed changes I was a bit skeptical at first, as I would generally rather prefer to slim django-image-cropping
a bit down (e.g. use vanilla JS instead of jQuery) than to add more functionality.
But from a first glance your commit looks really good and I really like the idea of encapsulating the easy_thumbnails
related code in a backend and make things more configurable.
Do you have an idea how to best deal with the cropping tag which also relies on easy_thumbnails
?
And do you see a good way to let users additionally install backends on demand so that they don't have to be bundled with the default installation?
Hi @anrie! Thanks for taking time to review.
In fact, all of those concerns are already addressed. Maybe we could just update the docs. I've already isolated all calls to methods of easy_thumbnails
, and those are now behind the Backend
facade.
The cropped_thumbnail
delegates the version generation to the backend.
The user can register any custom class as a backend by overriding the default settings. The IMAGE_CROPPING_BACKEND
expects a dotted path to a class that implements the required methods of a Backend:
IMAGE_CROPPING_BACKEND = 'image_cropping.backends.fb.FileBrowserBackend'
As an aditional layer of configuration, the user can provide an optional dict that will be used to populate the constructor of the backend, as in:
IMAGE_CROPPING_BACKEND_PARAMS = {'version_suffix': 'image_cropping'}
There's an Abstract Base Class to show the required methods of a custom backend.
The FileBrowserBackend
is an optional backend self-contained in a single file that is only imported if specified in the IMAGE_CROPPING_BACKEND
setting. I think that it is a good showcase on "how to write a custom backend".
Hey @fgmacedo, you are right, I didn't notice that you already took care of the cropping tag. Would you mind updating the docs and pointing out the new options? I see that I issue a new release in the next days. Thanks again for your contribution!
Hi @anrie, thanks for merging it.
I've updated the docs. I think that is ready for a PR, but I'm waiting the review of my PR to django-filebrowser in order to validate that the integration will work as planned.
This PR provides suport for
django-filebrowser
, as proposed at #91.easy_thumbnails
behind a private API in the form of abackend
.backends.base.ImageBackend
, but this ABC is provided only to documentation purposes and explicit inheritance is not verified in favor of duck typing.Adds a backend to allow usage with
django-filebrowser
.