From 4ab0dea44eeb236ee40fb08028c10fe8c031300a Mon Sep 17 00:00:00 2001
From: Jarmil <jarmil.halamicek@seznam.cz>
Date: Wed, 30 Sep 2020 11:58:36 +0200
Subject: [PATCH] Pridani titulku do galerie obrazku

---
 .../migrations/0004_auto_20200930_1156.py     | 41 +++++++++++++++++++
 program2021/models.py                         | 13 +++++-
 .../program2021/program2021_point_page.html   |  7 ++--
 3 files changed, 57 insertions(+), 4 deletions(-)
 create mode 100644 program2021/migrations/0004_auto_20200930_1156.py

diff --git a/program2021/migrations/0004_auto_20200930_1156.py b/program2021/migrations/0004_auto_20200930_1156.py
new file mode 100644
index 00000000..7c8bb8c2
--- /dev/null
+++ b/program2021/migrations/0004_auto_20200930_1156.py
@@ -0,0 +1,41 @@
+# Generated by Django 3.1.1 on 2020-09-30 09:56
+
+import wagtail.core.blocks
+import wagtail.core.fields
+import wagtail.images.blocks
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("program2021", "0003_program2021pointpage_image_title"),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name="program2021pointpage",
+            name="images",
+            field=wagtail.core.fields.StreamField(
+                [
+                    (
+                        "item",
+                        wagtail.core.blocks.StructBlock(
+                            [
+                                (
+                                    "image",
+                                    wagtail.images.blocks.ImageChooserBlock(
+                                        label="ilustrační obrázek"
+                                    ),
+                                ),
+                                ("title", wagtail.core.blocks.CharBlock(label="popis")),
+                            ],
+                            label="obrázek",
+                        ),
+                    )
+                ],
+                blank=True,
+                verbose_name="ilustrační obrázky",
+            ),
+        ),
+    ]
diff --git a/program2021/models.py b/program2021/models.py
index c13c6991..d0f7eb24 100644
--- a/program2021/models.py
+++ b/program2021/models.py
@@ -237,7 +237,18 @@ class Program2021PointPage(Page, MetadataPageMixin):
         blank=True,
     )
     images = StreamField(
-        [("image", ImageChooserBlock(label="ilustrační obrázek"))],
+        [
+            (
+                "item",
+                blocks.StructBlock(
+                    [
+                        ("image", ImageChooserBlock(label="ilustrační obrázek")),
+                        ("title", blocks.CharBlock(label="popis")),
+                    ],
+                    label="obrázek",
+                ),
+            ),
+        ],
         verbose_name="ilustrační obrázky",
         blank=True,
     )
diff --git a/program2021/templates/program2021/program2021_point_page.html b/program2021/templates/program2021/program2021_point_page.html
index 7bcdfcde..ea50b14b 100644
--- a/program2021/templates/program2021/program2021_point_page.html
+++ b/program2021/templates/program2021/program2021_point_page.html
@@ -96,10 +96,11 @@
     {% if page.images %}
     <div class="row about-images mb-5 mt-3 jumbotron">
       {% for block in page.images %}
-        {% image block.value width-2000 as img %}
-        {% image block.value fill-300x200 as thumb %}
+        {% image block.value.image width-2000 as img %}
+        {% image block.value.image fill-300x200 as thumb %}
         <div class="col-6 col-md-3 mb-4">
-          <a data-fancybox="gallery" href="{{ img.url }}"><img data-src="{{ thumb.url }}" class="lazyload img-fluid" alt="{{ thumb.alt }}"></a>
+          <a data-fancybox="gallery" href="{{ img.url }}"><img data-src="{{ thumb.url }}" class="lazyload img-fluid" alt="{{ block.value.title }}"></a><br>
+          {{ block.value.title }}
         </div><!-- /column -->
       {% endfor %}
     </div><!-- /row -->
-- 
GitLab