Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add product image alt field

Marcin Gębala70d90b54e328
diff --git a/saleor/dashboard/templates/dashboard/product/product_image_confirm_delete.html b/saleor/dashboard/templates/dashboard/product/product_image_confirm_delete.html
index b997a69a56..fb61c58521 100644
--- a/saleor/dashboard/templates/dashboard/product/product_image_confirm_delete.html
+++ b/saleor/dashboard/templates/dashboard/product/product_image_confirm_delete.html
@@ -11,7 +11,7 @@
{% csrf_token %}
<div class="row">
<div>{{ product_image.image.name }}</div>
- <div><img src="{{ product_image.image.crop.50x50}}" alt=""></div>
+ <div><img src="{{ product_image.image.crop.50x50}}" alt="{{ product_image.alt }}"></div>
</div>
<div class="row">
<button class="btn waves-effect red" type="submit"><i class="glyphicon glyphicon-trash"></i> {% trans "Delete" %}</button>
diff --git a/saleor/dashboard/templates/dashboard/product/product_images_list.html b/saleor/dashboard/templates/dashboard/product/product_images_list.html
index 3133d70664..7cdde4b3da 100644
--- a/saleor/dashboard/templates/dashboard/product/product_images_list.html
+++ b/saleor/dashboard/templates/dashboard/product/product_images_list.html
@@ -12,7 +12,7 @@
<ul class="collection">
{% for product_image in images %}
<li class="collection-item">
- <img src="{{ product_image.image.crop.50x50 }}" alt="">
+ <img src="{{ product_image.image.crop.50x50 }}" alt="{{ product_image.alt }}">
<span>{{ product_image.image.name }}</span>
<div class="right">
<a href="{% url 'dashboard:product-image-update' product_pk=product.pk img_pk=product_image.pk %}">{% trans 'Edit' %}</a>
diff --git a/saleor/product/models/images.py b/saleor/product/models/images.py
index cd3cf9a2ea..635507214d 100644
--- a/saleor/product/models/images.py
+++ b/saleor/product/models/images.py
@@ -1,6 +1,7 @@
from __future__ import unicode_literals
from django.db import models
+from django.utils.translation import pgettext_lazy
from versatileimagefield.fields import VersatileImageField, PPOIField
from .base import Product
@@ -16,6 +17,8 @@ class ProductImage(models.Model):
image = VersatileImageField(
upload_to='products', ppoi_field='ppoi', blank=False)
ppoi = PPOIField()
+ alt = models.CharField(
+ pgettext_lazy('Product image field', 'alternative text'), max_length=128, blank=True)
objects = ImageManager()