George Notaras  committed f056e99

A ThumbnailWorksError exception is raised if an empty or None ``name`` is provided to the ThumbnailFieldFile constructor.

  • Participants
  • Parent commits b1c7332

Comments (0)

Files changed (1)

File src/thumbnail_works/

 from django.db.models.fields.files import ImageField, ImageFieldFile
 from thumbnail_works.exceptions import ThumbnailOptionError
+from thumbnail_works.exceptions import ThumbnailWorksError
 from thumbnail_works import settings
 from thumbnail_works.images import ImageProcessor
             image processing options for this thumbnail as set in the
             ``thumbnails`` dictionary.
+        The ``name`` attribute cannot be empty. By default, ``name`` contains is
+        a path relative to MEDIA_ROOT, eg: ``myimages/image1.png`` and is
+        mandatory in order to have thumbnail management.
+        if not name:
+            raise ThumbnailWorksError('The provided name is not usable: "%s"')
         # Set the thumbnail identifier
         self.identifier = self.get_identifier(identifier)
         # Set the image processing options for this image (thumbnail)
         self.source = source
+        # Get a proper thumbnail name (relative path to MEDIA_ROOT)
         name = self.generate_image_name(name=name)
+        # is set by the following 
         super(BaseThumbnailFieldFile, self).__init__(instance, field, name)
     def get_identifier(self, identifier):