2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-12 07:54:14 +00:00

List API now uses the thumbnail image

This commit is contained in:
Oliver Walters
2020-04-05 00:19:37 +11:00
parent afa31b3415
commit 0cfb293ca9
5 changed files with 30 additions and 8 deletions

View File

@ -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/<x>/ 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']