Skip to content

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

Fix dashboard image sizes

weronkab38af2b7b5e0
diff --git a/templates/dashboard/product/list.html b/templates/dashboard/product/list.html
index fa6e1db100..b43539a003 100644
--- a/templates/dashboard/product/list.html
+++ b/templates/dashboard/product/list.html
@@ -3,7 +3,7 @@
{% load prices_i18n %}
{% load materializecss %}
{% load staticfiles %}
-{% load get_thumbnail from product_images %}
+{% load product_first_image from product_images %}
{% block title %}
{% trans "Products" context "Dashboard products list" %} - {{ block.super }}
@@ -41,11 +41,9 @@
{% for product in products %}
<li class="collection-item avatar list-item">
<a href="{% url 'dashboard:product-update' pk=product.pk %}">
- {% if product.images.exists %}
- <img src="{{ product.images.first.image.crop.100x100 }}" alt="" class="circle teal">
- {% else %}
- <img src="{% static 'images/product-image-placeholder-small.png' %}" alt="" class="circle teal">
- {% endif %}
+ <img src="{% product_first_image product size="60x60" method="crop" %}"
+ srcset="{% product_first_image product size="60x60" method="crop" %} 1x, {% product_first_image product size="120x120" method="crop" %} 2x"
+ alt="" class="circle teal">
<span class="title list-item-name">
{{ product.name }}
</span>
diff --git a/templates/dashboard/product/modal_product_confirm_delete.html b/templates/dashboard/product/modal_product_confirm_delete.html
index e90615d345..1779024e02 100644
--- a/templates/dashboard/product/modal_product_confirm_delete.html
+++ b/templates/dashboard/product/modal_product_confirm_delete.html
@@ -1,7 +1,7 @@
{% load i18n %}
{% load prices_i18n %}
{% load staticfiles %}
-{% load get_thumbnail from product_images %}
+{% load product_first_image from product_images %}
<form action="{% url "dashboard:product-delete" pk=product.pk %}" method="post" novalidate>
{% csrf_token %}
@@ -15,11 +15,9 @@
</div>
<div class="row">
<div class="col s12 center-align">
- {% if product.images.exists %}
- <img src="{{ product.images.first.image.crop.400x400 }}" alt="" class="responsive-img">
- {% else %}
- <img src="{% static 'images/product-image-placeholder.png' %}" alt="" class="responsive-img">
- {% endif %}
+ <img src="{% product_first_image product size="255x255" method="crop" %}"
+ srcset="{% product_first_image product size="255x255" method="crop" %} 1x, {% product_first_image product size="510x510" method="crop" %} 2x"
+ alt="" class="responsive-img">
</div>
</div>
<p>
diff --git a/templates/dashboard/product/modal_product_image_confirm_delete.html b/templates/dashboard/product/modal_product_image_confirm_delete.html
index 0864ff0296..1efbb7c8ae 100644
--- a/templates/dashboard/product/modal_product_image_confirm_delete.html
+++ b/templates/dashboard/product/modal_product_image_confirm_delete.html
@@ -1,4 +1,5 @@
{% load i18n %}
+{% load product_first_image from product_images %}
<form action="{% url 'dashboard:product-image-delete' product_pk=product.pk img_pk=product_image.pk %}" method="post" novalidate>
{% csrf_token %}
@@ -12,7 +13,9 @@
</div>
</div>
<div class="center-align">
- <img class="responsive-img" src="{{ product_image.image.crop.400x400 }}" alt="">
+ <img class="responsive-img" src="{% product_first_image product size="255x255" method="crop" %}"
+ srcset="{% product_first_image product size="255x255" method="crop" %} 1x, {% product_first_image product size="510x510" method="crop" %} 2x"
+ alt="">
</div>
<p>
{% blocktrans trimmed context "Modal delete image text" %}
diff --git a/templates/dashboard/product/product_confirm_delete.html b/templates/dashboard/product/product_confirm_delete.html
index 505ca7740c..7ffa3a936e 100644
--- a/templates/dashboard/product/product_confirm_delete.html
+++ b/templates/dashboard/product/product_confirm_delete.html
@@ -2,7 +2,7 @@
{% load i18n %}
{% load prices_i18n %}
{% load staticfiles %}
-{% load get_thumbnail from product_images %}
+{% load product_first_image from product_images %}
{% block title %}
{% trans "Delete" context "Dashboard delete action" %} {{ product }} - {{ block.super }}
@@ -49,11 +49,9 @@
<div class="col m6 l4">
<div class="card">
<div class="card-content">
- {% if object.images.exists %}
- <img src="{{ product.images.first.image.crop.400x400 }}" alt="" class="responsive-img">
- {% else %}
- <img src="{% static 'images/product-image-placeholder.png' %}" alt="" class="responsive-img">
- {% endif %}
+ <img src="{% product_first_image product size="255x255" method="crop" %}"
+ srcset="{% product_first_image product size="255x255" method="crop" %} 1x, {% product_first_image product size="510x510" method="crop" %} 2x"
+ alt="" class="responsive-img">
</div>
<div class="card-action">
<button type="submit" class="card-link">
diff --git a/templates/dashboard/product/product_form.html b/templates/dashboard/product/product_form.html
index 6b0efd7f5f..ab479bbb36 100644
--- a/templates/dashboard/product/product_form.html
+++ b/templates/dashboard/product/product_form.html
@@ -385,7 +385,10 @@
<div class="row">
<div class="card">
<div class="card-image product-gallery-item-image">
- <img class="responsive-img" src="{{ image.image.crop.400x400 }}" alt="">
+ <img class="responsive-img"
+ src="{{ image.image.crop.255x255 }}"
+ srcset="{{ image.image.crop.255x255 }} 1x, {{ image.image.crop.510x510 }} 2x"
+ alt="">
</div>
<div class="card-content">
<span class="product-gallery-item-title card-title black-text" title="{{ image.alt }}">
diff --git a/templates/dashboard/product/product_image_confirm_delete.html b/templates/dashboard/product/product_image_confirm_delete.html
index 44d849b57c..5e776d5b38 100644
--- a/templates/dashboard/product/product_image_confirm_delete.html
+++ b/templates/dashboard/product/product_image_confirm_delete.html
@@ -1,5 +1,6 @@
{% extends "dashboard/base.html" %}
{% load i18n %}
+{% load product_first_image from product_images %}
{% block title %}
{% trans "Delete image" context "Delete image page title" %} - {{ block.super }}
@@ -44,7 +45,9 @@
<div class="card-title black-text">
{{ product_image.alt }}
</div>
- <img src="{{ product_image.image.crop.400x400}}" alt="{{ product_image.alt }}" class="responsive-img">
+ <img src="{% product_first_image product size="255x255" method="crop" %}"
+ srcset="{% product_first_image product size="255x255" method="crop" %} 1x, {% product_first_image product size="510x510" method="crop" %} 2x"
+ alt="{{ product_image.alt }}" class="responsive-img">
</div>
</div>
</div>
diff --git a/templates/dashboard/search/results.html b/templates/dashboard/search/results.html
index 3ac4016c11..0ac0985e95 100644
--- a/templates/dashboard/search/results.html
+++ b/templates/dashboard/search/results.html
@@ -38,8 +38,9 @@
{% if result.content_type == 'product_product' %}
{% with product=result %}
<a href="{% url 'dashboard:product-update' pk=product.pk %}">
- <img src="{% product_first_image product size="100x100" method="crop" %}"
- class="circle teal" alt="{{ product.name }}">
+ <img src="{% product_first_image product size="60x60" method="crop" %}"
+ srcset="{% product_first_image product size="60x60" method="crop" %} 1x, {% product_first_image product size="120x120" method="crop" %} 2x"
+ class="circle teal" alt="{{ product.name }}">
<span class="list-item-name">
{{ product.name }}
</span>