send_locally_feed.py: use profile images

This commit is contained in:
2020-02-19 13:07:23 -08:00
parent 908793d077
commit dc01f894f7
2 changed files with 7 additions and 5 deletions

View File

@ -116,7 +116,9 @@ class Command(BaseCommand):
def image_url(self, material): def image_url(self, material):
paths = ProductImage.get_all_image_urls(material, ProductImageFormat.MED_JPG, True) views = ['P', 'P2', 'PLA', 'FRONT'] # only want side views
paths = ProductImage.get_all_image_urls(material, ProductImageFormat.MED_JPG,
view_types=views, full_url=True)
if len(paths) > 0: if len(paths) > 0:
return paths[0] return paths[0]
else: else:

View File

@ -92,9 +92,9 @@ class ProductImage:
# return path # return path
@staticmethod @staticmethod
def get_all_image_paths(sap, image_format): def get_all_image_paths(sap, image_format, view_types=VIEW_TYPES):
paths = [] paths = []
for view in ProductImage.VIEW_TYPES: for view in view_types:
path = os.path.join(ProductImage.THUMB_DIR, path = os.path.join(ProductImage.THUMB_DIR,
'{}_{}-{}'.format(sap, view, image_format.value)) '{}_{}-{}'.format(sap, view, image_format.value))
if os.path.isfile(path): if os.path.isfile(path):
@ -108,8 +108,8 @@ class ProductImage:
# return path.replace(ProductImage.THUMB_DIR, ProductImage.THUMB_URL) # return path.replace(ProductImage.THUMB_DIR, ProductImage.THUMB_URL)
@staticmethod @staticmethod
def get_all_image_urls(sap, image_format, full_url=False): def get_all_image_urls(sap, image_format, view_types=VIEW_TYPES, full_url=False):
paths = ProductImage.get_all_image_paths(sap, image_format) paths = ProductImage.get_all_image_paths(sap, image_format, view_types)
url_prefix = ProductImage.THUMB_URL url_prefix = ProductImage.THUMB_URL
if full_url: if full_url:
url_prefix = f'https://{settings.PUBLIC_WEB_HOST}{url_prefix}' url_prefix = f'https://{settings.PUBLIC_WEB_HOST}{url_prefix}'