Skip to content

Commit

Permalink
Optimise image renditions; change to JPG, set quality (#1503)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood authored Jan 11, 2024
2 parents badd316 + 1a814b8 commit 8bd13ae
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion etna/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class CustomImagesAPIViewSet(ImagesAPIViewSet):
"description",
# APIField(
# "image_small_jpg",
# serializer=ImageRenditionField("fill-128x128", source="file"),
# serializer=ImageRenditionField("fill-128x128|format-jpeg|jpegquality-60", source="file"),
# ),
]

Expand Down
4 changes: 3 additions & 1 deletion etna/articles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,9 @@ class Meta:
# APIField("promote_panels"),
APIField(
"intro_image_jpg",
serializer=ImageRenditionField("fill-512x512", source="intro_image"),
serializer=ImageRenditionField(
"fill-512x512|format-jpeg|jpegquality-60", source="intro_image"
),
),
# APIField("content_panels"),
# APIField("gallery_items"),
Expand Down
8 changes: 6 additions & 2 deletions etna/authors/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,15 @@ class Meta:
),
APIField(
"image_jpg",
serializer=ImageRenditionField("fill-512x512", source="image"),
serializer=ImageRenditionField(
"fill-512x512|format-jpeg|jpegquality-60", source="image"
),
),
APIField(
"image_small_jpg",
serializer=ImageRenditionField("fill-128x128", source="image"),
serializer=ImageRenditionField(
"fill-128x128|format-jpeg|jpegquality-60", source="image"
),
),
]

Expand Down
12 changes: 9 additions & 3 deletions etna/core/models/basepage.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ def get_datalayer_data(self, request: HttpRequest) -> Dict[str, Any]:
APIField("teaser_text"),
APIField(
"teaser_image_jpg",
serializer=ImageRenditionField("fill-600x400", source="teaser_image"),
serializer=ImageRenditionField(
"fill-600x400|format-jpeg|jpegquality-60", source="teaser_image"
),
),
APIField(
"teaser_image_webp",
Expand All @@ -161,7 +163,9 @@ def get_datalayer_data(self, request: HttpRequest) -> Dict[str, Any]:
),
APIField(
"teaser_image_large_jpg",
serializer=ImageRenditionField("fill-1200x800", source="teaser_image"),
serializer=ImageRenditionField(
"fill-1200x800|format-jpeg|jpegquality-60", source="teaser_image"
),
),
APIField(
"teaser_image_large_webp",
Expand All @@ -171,7 +175,9 @@ def get_datalayer_data(self, request: HttpRequest) -> Dict[str, Any]:
),
APIField(
"teaser_image_square_jpg",
serializer=ImageRenditionField("fill-512x512", source="teaser_image"),
serializer=ImageRenditionField(
"fill-512x512|format-jpeg|jpegquality-60", source="teaser_image"
),
),
APIField(
"teaser_image_square_webp",
Expand Down
8 changes: 6 additions & 2 deletions etna/core/models/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ class Meta:
APIField("hero_image_caption"),
APIField(
"hero_image_jpg",
serializer=ImageRenditionField("fill-1200x400", source="hero_image"),
serializer=ImageRenditionField(
"fill-1200x400|format-jpeg|jpegquality-60", source="hero_image"
),
),
APIField(
"hero_image_webp",
Expand All @@ -171,7 +173,9 @@ class Meta:
),
APIField(
"hero_image_jpg_small",
serializer=ImageRenditionField("fill-600x400", source="hero_image"),
serializer=ImageRenditionField(
"fill-600x400|format-jpeg|jpegquality-60", source="hero_image"
),
),
APIField(
"hero_image_webp_small",
Expand Down

0 comments on commit 8bd13ae

Please sign in to comment.