easy-thumbnails icon indicating copy to clipboard operation
easy-thumbnails copied to clipboard

Optimize for alternate storage backends

Open damianmoore opened this issue 11 years ago • 1 comments

At the digital agency I work for we use Amazon's S3 for our image storage in production. We found your optimization post-processor and it worked well in development. However, when we went live we noticed the images were no longer being optimised.

The Django package we use is called django-storages: http://django-storages.readthedocs.org/en/latest/index.html

After digging into the post_processor.py I found that thumbnail.path is not set for cloud-based storage providers and raises a NotImplementedError. In this case I detect the file-type from the url attribute and save the file referenced by the name attribute.

I confirm this is working with S3 but it should be generic enough to work with most other storage backends.

damianmoore avatar Jul 03 '14 15:07 damianmoore

Cheers for this, I think that we should add a test showing what's going on here. Rather than just using os.path.splitext, how about using mimetypes.guess_type and splitting on /, taking the subtype. And we don't need to do it against .url -- .name should be enough

SmileyChris avatar Jul 11 '14 04:07 SmileyChris