send_locally_feed.py: use profile images
This commit is contained in:
@ -116,7 +116,9 @@ class Command(BaseCommand):
|
||||
|
||||
|
||||
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:
|
||||
return paths[0]
|
||||
else:
|
||||
|
||||
@ -92,9 +92,9 @@ class ProductImage:
|
||||
# return path
|
||||
|
||||
@staticmethod
|
||||
def get_all_image_paths(sap, image_format):
|
||||
def get_all_image_paths(sap, image_format, view_types=VIEW_TYPES):
|
||||
paths = []
|
||||
for view in ProductImage.VIEW_TYPES:
|
||||
for view in view_types:
|
||||
path = os.path.join(ProductImage.THUMB_DIR,
|
||||
'{}_{}-{}'.format(sap, view, image_format.value))
|
||||
if os.path.isfile(path):
|
||||
@ -108,8 +108,8 @@ class ProductImage:
|
||||
# return path.replace(ProductImage.THUMB_DIR, ProductImage.THUMB_URL)
|
||||
|
||||
@staticmethod
|
||||
def get_all_image_urls(sap, image_format, full_url=False):
|
||||
paths = ProductImage.get_all_image_paths(sap, image_format)
|
||||
def get_all_image_urls(sap, image_format, view_types=VIEW_TYPES, full_url=False):
|
||||
paths = ProductImage.get_all_image_paths(sap, image_format, view_types)
|
||||
url_prefix = ProductImage.THUMB_URL
|
||||
if full_url:
|
||||
url_prefix = f'https://{settings.PUBLIC_WEB_HOST}{url_prefix}'
|
||||
|
||||
Reference in New Issue
Block a user