diff --git a/django_lostplaces/lostplaces/models.py b/django_lostplaces/lostplaces/models.py index 049999e..2cfa5e9 100644 --- a/django_lostplaces/lostplaces/models.py +++ b/django_lostplaces/lostplaces/models.py @@ -144,20 +144,25 @@ class Place(Submittable, Taggable, Mapable): def generate_image_upload_path(instance, filename): """ Callback for generating path for uploaded images. + Returns filename as: placepk-placename{-rndstring}.jpg """ - return 'places/' + str(uuid.uuid4())+'.'+filename.split('.')[-1] + return 'places/' + str(instance.place.pk) + '-' + str(instance.place.name) + '.' + filename.split('.')[-1] class PlaceImage (Submittable): """ PlaceImage defines an image file object that points to a file in uploads/. - Intermediate image sizes are generated as defined in SIZES. + Intermediate image sizes are generated as defined in THUMBNAIL_ALIASES. PlaceImage references a Place to which it belongs. """ description = models.TextField(blank=True) - filename = ThumbnailerImageField(upload_to=generate_image_upload_path) + filename = ThumbnailerImageField( + upload_to=generate_image_upload_path, + resize_source=dict(size=(2560, 2560), + sharpen=True) + ) place = models.ForeignKey( Place, on_delete=models.CASCADE,