Resize original images, name files with placename in filename, sharpen.
This commit is contained in:
parent
b0e775d299
commit
74a9ee4f39
@ -144,20 +144,25 @@ class Place(Submittable, Taggable, Mapable):
|
|||||||
def generate_image_upload_path(instance, filename):
|
def generate_image_upload_path(instance, filename):
|
||||||
"""
|
"""
|
||||||
Callback for generating path for uploaded images.
|
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):
|
class PlaceImage (Submittable):
|
||||||
"""
|
"""
|
||||||
PlaceImage defines an image file object that points to a file in uploads/.
|
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.
|
PlaceImage references a Place to which it belongs.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
description = models.TextField(blank=True)
|
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 = models.ForeignKey(
|
||||||
Place,
|
Place,
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
|
Loading…
Reference in New Issue
Block a user