Ilustr sizes in json for app
[wolnelektury.git] / src / catalogue / utils.py
index 2469d6c..60de555 100644 (file)
@@ -332,3 +332,14 @@ def iter_file(field_file, chunk_size=CHUNK_SIZE):
     else:
         with field_file.open("rb") as f:
             yield from f.chunks(chunk_size)
+
+
+# TODO: this should be recorded when generated.
+ILUSTR_SIZES = [360, 600, 1200, 1800, 2400]
+def get_ilustr_sizes(src, slug, index):
+    ext = src.rsplit('.', 1)[-1]
+    gallery = absolute_url(gallery_url(slug))
+    return {
+        str(size): f"{gallery}{index}.W{size}.{ext}"
+        for size in ILUSTR_SIZES
+    }