George Notaras avatar George Notaras committed d8d7cad

Fixed bug: The existence of the thumbnail files on the storage should always be checked before adding the thumbnail objects as attributes of the source image

Comments (0)

Files changed (1)

src/thumbnail_works/fields.py

             deleted from the filesystem.
         
         Thumbnails are set as attributes of the ``BaseEnhancedImageFieldFile``
-        object (source image) according to the following rules:
+        object (source image) only if they exist on the storage.
         
-        - If the ``THUMBNAILS_DELAYED_GENERATION`` setting has been enabled, then
-          each thumbnail is set as an attribute of the source image only if the
-          thumbnail file exists on the storage. In the case that the thumbnail
-          does not exist on the storage, it will be generated as soon as it is
-          accessed for the first time. The attribute will be set at that time.
-        - If the ``THUMBNAILS_DELAYED_GENERATION`` is not enabled, then
-          all thumbnails are set as attributes of the ``BaseEnhancedImageFieldFile``
-          object without performing any checks whether the file exists on the
-          storage or not. The thumbnails are expected to have already been
-          generated when the source image was saved.
+        If the thumbnail files are not found on the storage at this time, they
+        will be generated the first time they are accessed regardless of the
+        THUMBNAILS_DELAYED_GENERATION ``setting``.
         
         """
         # Set the identifier to None. Only thumbnails have an identifier attribute
         if self._committed and self.field.thumbnails:
             for identifier, proc_opts in self.field.thumbnails.items():
                 t = ThumbnailFieldFile(self.instance, self.field, self, self.name, identifier, proc_opts)
-                if settings.THUMBNAILS_DELAYED_GENERATION:
-                    if self.storage.exists(t.name):
-                        setattr(self, identifier, t)
-                else:
+                if self.storage.exists(t.name):
                     setattr(self, identifier, t)
     
     def __getattr__(self, attribute):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.