Skip to content
Snippets Groups Projects

Allow a worker to specify the needed size of the image

Merged Manon Blanco requested to merge resize-image into master
All threads resolved!
4 files
+ 7
23
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 1
10
@@ -157,17 +157,8 @@ class CachedElement(Model):
max_height is None or self.image.height <= max_height
):
resize = "full"
elif max_width is not None and max_height is not None:
resize = f"{max_width},{max_height}"
else:
ratio = max(
(max_width or 0) / self.image.width,
(max_height or 0) / self.image.height,
)
new_width, new_height = int(self.image.width * ratio), int(
self.image.height * ratio
)
resize = f"{new_width},{new_height}"
resize = f"{max_width or ''},{max_height or ''}"
url = self.image.url
if not url.endswith("/"):
Loading