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

thumbnail_storage is None by default #1

Closed
lincolnloop opened this issue Oct 16, 2009 · 3 comments
Closed

thumbnail_storage is None by default #1

lincolnloop opened this issue Oct 16, 2009 · 3 comments

Comments

@lincolnloop
Copy link

In [6]: l.image.generate_thumbnail({'size':(50,50)})
---------------------------------------------------------------------------
        Traceback (most recent call last)

/home/pete/sandbox/cloudfiles/project/ in ()

/home/pete/sandbox/cloudfiles/src/easy-thumbnails/easy_thumbnails/files.py in generate_thumbnail(self, thumbnail_options)
    176         filename = self.get_thumbnail_name(thumbnail_options)
    177         thumbnail = ThumbnailFile(filename, ContentFile(data),
--> 178                                   storage=self.thumbnail_storage)
    179         thumbnail.image = thumbnail_image
    180         thumbnail._committed = False

: 'ThumbnailerImageFieldFile' object has no attribute 'thumbnail_storage'

This fixes the issue:

diff --git a/easy_thumbnails/fields.py b/easy_thumbnails/fields.py
index d49af50..ee77d2e 100644
--- a/easy_thumbnails/fields.py
+++ b/easy_thumbnails/fields.py
@@ -16,10 +16,11 @@ class ThumbnailerField(FileField):
     def __init__(self, *args, **kwargs):
         # Arguments not explicitly defined so that the normal ImageField
         # positional arguments can be used.
-        self.thumbnail_storage = kwargs.pop('thumbnail_storage', None)
         
         super(ThumbnailerField, self).__init__(*args, **kwargs)
 
+        self.thumbnail_storage = kwargs.pop('thumbnail_storage', self.storage)
+
     def south_field_triple(self):
         """
         Return a suitable description of this field for South.
@SmileyChris
Copy link
Owner

Hrm... think this is due to django's FieldFile not using super() in it's init method... grr.

@SmileyChris
Copy link
Owner

Odd, can't seem to reproduce this in a test: have a look at 2affc77

@SmileyChris
Copy link
Owner

ThumbnailerFieldFile now subclasses Thumbnailer, which sets self.thumbnail_storage

This issue was closed.
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