diff --git a/InvenTree/InvenTree/static/script/inventree/part.js b/InvenTree/InvenTree/static/script/inventree/part.js
index dceb08dd5f..665701defd 100644
--- a/InvenTree/InvenTree/static/script/inventree/part.js
+++ b/InvenTree/InvenTree/static/script/inventree/part.js
@@ -139,7 +139,7 @@ function loadPartTable(table, url, options={}) {
name = '' + name + '';
}
- var display = imageHoverIcon(row.image) + renderLink(name, '/part/' + row.pk + '/');
+ var display = imageHoverIcon(row.thumbnail) + renderLink(name, '/part/' + row.pk + '/');
if (row.is_template) {
display = display + "TEMPLATE";
diff --git a/InvenTree/InvenTree/static/script/inventree/stock.js b/InvenTree/InvenTree/static/script/inventree/stock.js
index 2a06808690..60978f8091 100644
--- a/InvenTree/InvenTree/static/script/inventree/stock.js
+++ b/InvenTree/InvenTree/static/script/inventree/stock.js
@@ -70,7 +70,7 @@ function loadStockTable(table, options) {
name += row.part__name;
- return imageHoverIcon(row.part__image) + name + ' (' + data.length + ' items)';
+ return imageHoverIcon(row.part__thumbnail) + name + ' (' + data.length + ' items)';
}
else if (field == 'part__description') {
return row.part__description;
@@ -188,7 +188,7 @@ function loadStockTable(table, options) {
name += row.part__revision;
}
- return imageHoverIcon(row.part__image) + renderLink(name, '/part/' + row.part + '/stock/');
+ return imageHoverIcon(row.part__thumbnail) + renderLink(name, '/part/' + row.part + '/stock/');
}
},
{
diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py
index 55e711ff5f..ec599de446 100644
--- a/InvenTree/part/api.py
+++ b/InvenTree/part/api.py
@@ -221,7 +221,17 @@ class PartList(generics.ListCreateAPIView):
for item in data:
if item['image']:
- item['image'] = os.path.join(settings.MEDIA_URL, item['image'])
+ img = item['image']
+
+ # Use the 'thumbnail' image here instead of the full-size image
+ # Note: The full-size image is used when requesting the /api/part// endpoint
+ fn, ext = os.path.splitext(img)
+
+ thumb = "{fn}.thumbnail{ext}".format(fn=fn, ext=ext)
+
+ item['thumbnail'] = os.path.join(settings.MEDIA_URL, thumb)
+
+ del item['image']
cat_id = item['category']
diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py
index 1c7ae6f4ca..a48aaaa54d 100644
--- a/InvenTree/part/serializers.py
+++ b/InvenTree/part/serializers.py
@@ -47,7 +47,7 @@ class PartBriefSerializer(InvenTreeModelSerializer):
""" Serializer for Part (brief detail) """
url = serializers.CharField(source='get_absolute_url', read_only=True)
- image_url = serializers.CharField(source='get_image_url', read_only=True)
+ image_url = serializers.CharField(source='get_thumbnail_url', read_only=True)
@staticmethod
def setup_eager_loading(queryset):
@@ -79,7 +79,8 @@ class PartSerializer(InvenTreeModelSerializer):
"""
url = serializers.CharField(source='get_absolute_url', read_only=True)
- image_url = serializers.CharField(source='get_image_url', read_only=True)
+ image = serializers.CharField(source='get_image_url', read_only=True)
+ thumbnail = serializers.CharField(source='get_thumbnail_url', read_only=True)
category_name = serializers.CharField(source='category_path', read_only=True)
allocated_stock = serializers.IntegerField(source='allocation_count', read_only=True)
@@ -100,7 +101,8 @@ class PartSerializer(InvenTreeModelSerializer):
'url', # Link to the part detail page
'category',
'category_name',
- 'image_url',
+ 'image',
+ 'thumbnail',
'full_name',
'name',
'IPN',
diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py
index 3eb183ce35..3c3e5acce6 100644
--- a/InvenTree/stock/api.py
+++ b/InvenTree/stock/api.py
@@ -337,7 +337,17 @@ class StockList(generics.ListCreateAPIView):
locations = {}
for item in data:
- item['part__image'] = os.path.join(settings.MEDIA_URL, item['part__image'])
+
+ img = item['part__image']
+
+ # Use the thumbnail image instead
+ fn, ext = os.path.splitext(img)
+
+ thumb = "{fn}.thumbnail{ext}".format(fn=fn, ext=ext)
+
+ item['part__thumbnail'] = os.path.join(settings.MEDIA_URL, thumb)
+
+ del item['part__image']
loc_id = item['location']