Skip to content

Commit

Permalink
CONCD-680 Campaign.alt_image_text field (Requires Migration)
Browse files Browse the repository at this point in the history
  • Loading branch information
rasarkar committed Feb 26, 2024
1 parent bb3dbbf commit 19db3f1
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
18 changes: 18 additions & 0 deletions concordia/migrations/0089_campaign_image_alt_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.24 on 2024-02-26 14:13

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("concordia", "0088_alter_simplepage_body"),
]

operations = [
migrations.AddField(
model_name="campaign",
name="image_alt_text",
field=models.TextField(blank=True, null=True),
),
]
1 change: 1 addition & 0 deletions concordia/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ class Status(models.IntegerChoices):
card_family = models.ForeignKey(
CardFamily, on_delete=models.CASCADE, blank=True, null=True
)
image_alt_text = models.TextField(blank=True, null=True)
thumbnail_image = models.ImageField(
upload_to="campaign-thumbnails", blank=True, null=True
)
Expand Down
2 changes: 1 addition & 1 deletion concordia/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ <h2 class="text-center font-serif mb-4">Campaigns: <small>Choose which collectio
<a class="text-dark" href="{{ campaign_url }}">
<div class="aspect-ratio-box">
<div class="aspect-ratio-box-inner-wrapper">
<img src="{{ MEDIA_URL }}{{ campaign.thumbnail_image }}" class="img-fluid" alt="" loading="lazy">
<img src="{{ MEDIA_URL }}{{ campaign.thumbnail_image }}" class="img-fluid" alt="{{ campaign.image_alt_text }}" loading="lazy">
</div>
</div>
<span class="d-block h4 mt-2">{{ campaign.title }}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<a href="{% url 'transcriptions:campaign-detail' campaign.slug %}">
<div class="aspect-ratio-box">
<div class="aspect-ratio-box-inner-wrapper">
<img src="{{ MEDIA_URL }}{{ campaign.thumbnail_image }}" class="img-fluid" alt="" loading="lazy">
<img src="{{ MEDIA_URL }}{{ campaign.thumbnail_image }}" class="img-fluid" alt="{{ campaign.alt_image_text}}" loading="lazy">
</div>
</div>
<span class="d-block h4 mt-2 small-campaign-title">{{ campaign.title }}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h2 class="p-2">Active Campaigns</h2>
<h3 class="mb-3"><a href="{{ campaign.get_absolute_url }}">{{ campaign.title }}</a></h3>
<div class="row">
<a class="col-md-5 order-md-2" href="{{ campaign.get_absolute_url }}">
<p class="mb-2 text-center"><img src="{{ MEDIA_URL }}{{ campaign.thumbnail_image }}" class="img-fluid" alt="{{ campaign.title }} image"></p>
<p class="mb-2 text-center"><img src="{{ MEDIA_URL }}{{ campaign.thumbnail_image }}" class="img-fluid" alt="{% if campaign.image_alt_text %}{{ campaign.image_alt_text }}{% else %}{{ campaign.title }} image{% endif %}"></p>
</a>
<div class="col-md">
<p>{{ campaign.short_description|safe }}</p>
Expand Down

0 comments on commit 19db3f1

Please sign in to comment.