quickinfo: show all images for a material

This commit is contained in:
2020-01-17 21:55:35 -08:00
parent bdce950581
commit d7159b6765
3 changed files with 35 additions and 12 deletions

View File

@ -60,19 +60,34 @@ class ProductImage:
'T', 'TL', 'PACK', 'F', 'B', 'INT', 'ALT_INT', 'FLR',
'FRONT', 'BACK']
# @staticmethod
# def get_image_path(sap, image_format):
# for view in ProductImage.VIEW_TYPES:
# path = os.path.join(ProductImage.THUMB_DIR,
# '{}_{}-{}'.format(sap, view, image_format.value))
# if os.path.isfile(path):
# return path
@staticmethod
def get_image_path(sap, image_format):
def get_all_image_paths(sap, image_format):
paths = []
for view in ProductImage.VIEW_TYPES:
path = os.path.join(ProductImage.THUMB_DIR,
'{}_{}-{}'.format(sap, view, image_format.value))
if os.path.isfile(path):
return path
paths.append(path)
return paths
# @staticmethod
# def get_image_url(sap, image_format):
# path = ProductImage.get_image_path(sap, image_format)
# if path:
# return path.replace(ProductImage.THUMB_DIR, ProductImage.THUMB_URL)
@staticmethod
def get_image_url(sap, image_format):
path = ProductImage.get_image_path(sap, image_format)
if path:
return path.replace(ProductImage.THUMB_DIR, ProductImage.THUMB_URL)
def get_all_image_urls(sap, image_format):
paths = ProductImage.get_all_image_paths(sap, image_format)
return [p.replace(ProductImage.THUMB_DIR, ProductImage.THUMB_URL) for p in paths]