products/models.py: get_all_image_urls() add option for full url

This commit is contained in:
2020-02-13 16:39:09 -08:00
parent 9cbf48383c
commit c2755c95d8

View File

@ -108,9 +108,12 @@ class ProductImage:
# return path.replace(ProductImage.THUMB_DIR, ProductImage.THUMB_URL)
@staticmethod
def get_all_image_urls(sap, image_format):
def get_all_image_urls(sap, image_format, full_url=False):
paths = ProductImage.get_all_image_paths(sap, image_format)
return [p.replace(ProductImage.THUMB_DIR, ProductImage.THUMB_URL) for p in paths]
url_prefix = ProductImage.THUMB_URL
if full_url:
url_prefix = f'https://{settings.PUBLIC_WEB_HOST}{url_prefix}'
return [p.replace(ProductImage.THUMB_DIR, url_prefix) for p in paths]