Only load Image once when creating all three Thumbnail sizes.

This commit is contained in:
Will Stott
2019-07-18 14:42:40 +01:00
parent cb24cebd94
commit 510966633a
10 changed files with 122 additions and 140 deletions

View File

@@ -35,8 +35,7 @@ class ImageManager(models.Manager):
# a chance of getting Database into a inconsistent state when we
# try to create thumbnails one by one later
image = self.create(image=obj)
for size in settings.IMAGE_SIZES.keys():
Thumbnail.objects.get_or_create_at_size(image, size)
Thumbnail.objects.get_or_create_at_sizes(image, settings.IMAGE_SIZES.keys())
return image