diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index e032c73eeb..9b73f68973 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -225,11 +225,17 @@ class PartList(generics.ListCreateAPIView): # 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) + if img: + fn, ext = os.path.splitext(img) - item['thumbnail'] = os.path.join(settings.MEDIA_URL, thumb) + thumb = "{fn}.thumbnail{ext}".format(fn=fn, ext=ext) + + thumb = os.path.join(settings.MEDIA_URL, thumb) + else: + thumb = '' + + item['thumbnail'] = thumb del item['image'] diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index 3c3e5acce6..53d4b15d13 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -340,12 +340,17 @@ class StockList(generics.ListCreateAPIView): img = item['part__image'] - # Use the thumbnail image instead - fn, ext = os.path.splitext(img) + if img: + # Use the thumbnail image instead + fn, ext = os.path.splitext(img) - thumb = "{fn}.thumbnail{ext}".format(fn=fn, ext=ext) + thumb = "{fn}.thumbnail{ext}".format(fn=fn, ext=ext) - item['part__thumbnail'] = os.path.join(settings.MEDIA_URL, thumb) + thumb = os.path.join(settings.MEDIA_URL, thumb) + else: + thumb = '' + + item['part__thumbnail'] = thumb del item['part__image']