Add justified photo grid layout with lazy loading and image dimensions, increase thumbnail resolution
This commit is contained in:
parent
8e217a51a0
commit
76719e24f3
6 changed files with 186 additions and 6 deletions
36
photologue/migrations/0008_regen_thumbnails.py
Normal file
36
photologue/migrations/0008_regen_thumbnails.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
from django.db import migrations
|
||||
|
||||
|
||||
def regen_thumbnails(apps, schema_editor):
|
||||
Photo = apps.get_model("photologue", "Photo")
|
||||
PhotoSize = apps.get_model("photologue", "PhotoSize")
|
||||
|
||||
try:
|
||||
thumbnail = PhotoSize.objects.get(name="thumbnail")
|
||||
except PhotoSize.DoesNotExist:
|
||||
return
|
||||
|
||||
thumbnail.width = 600
|
||||
thumbnail.height = 0
|
||||
thumbnail.crop = False
|
||||
thumbnail.save()
|
||||
|
||||
for photo in Photo.objects.all():
|
||||
# Use the real model instance to access file methods
|
||||
from photologue.models import Photo as RealPhoto
|
||||
try:
|
||||
real_photo = RealPhoto.objects.get(pk=photo.pk)
|
||||
real_photo.remove_size(thumbnail)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("photologue", "0007_photo_dimensions"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(regen_thumbnails, migrations.RunPython.noop),
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue