diff --git a/app/blueprints/api.py b/app/blueprints/api.py index 05dee95..ad09550 100644 --- a/app/blueprints/api.py +++ b/app/blueprints/api.py @@ -263,10 +263,11 @@ def get_search(): image_url = '' try: - accession_number_int = int(unit.accession_number) - instance_id = f'{accession_number_int:06}' - first_3 = instance_id[0:3] - image_url = f'https://brmas-pub.s3-ap-northeast-1.amazonaws.com/hast/{first_3}/S_{instance_id}_s.jpg' + #accession_number_int = int(unit.accession_number) + #instance_id = f'{accession_number_int:06}' + #first_3 = instance_id[0:3] + #image_url = f'https://brmas-pub.s3-ap-northeast-1.amazonaws.com/hast/{first_3}/S_{instance_id}_s.jpg' + image_url = unit.get_image() except: pass diff --git a/app/models/collection.py b/app/models/collection.py index 81d648e..37ad8ff 100644 --- a/app/models/collection.py +++ b/app/models/collection.py @@ -965,7 +965,7 @@ def get_annotation(self, type_name='', part=''): if x.annotation_type.name == type_name: return getattr(x, part) if part else x - def get_image(self, thumbnail='_s'): + def get_image(self, thumbnail='s'): if self.collection_id == 1: #if self.multimedia_objects: # accession_number_int = int(self.accession_number) @@ -973,11 +973,14 @@ def get_image(self, thumbnail='_s'): # thumbnail = thumbnail.replace('_', '-') # return f'https://pid.biodiv.tw/ark:/18474/v6cc0ts6j/S_{id_}{thumbnail}.jpg' try: - accession_number_int = int(self.accession_number) - instance_id = f'{accession_number_int:06}' - first_3 = instance_id[0:3] - image_url = f'https://brmas-pub.s3-ap-northeast-1.amazonaws.com/hast/{first_3}/S_{instance_id}{thumbnail}.jpg' - return image_url + #accession_number_int = int(self.accession_number) + #instance_id = f'{accession_number_int:06}' + #first_3 = instance_id[0:3] + #image_url = f'https://brmas-pub.s3-ap-northeast-1.amazonaws.com/hast/{first_3}/S_{instance_id}{thumbnail}.jpg' + if self.accession_number: + return f'https://brmas-media.s3.ap-northeast-1.amazonaws.com/hast/specimen/S_{int(self.accession_number):06}-{thumbnail}.jpg' + else: + return None except: pass # TODO, get first cover or other type diff --git a/app/templates/sites/hast/specimen-detail.html b/app/templates/sites/hast/specimen-detail.html index 80cb413..aee2e1c 100644 --- a/app/templates/sites/hast/specimen-detail.html +++ b/app/templates/sites/hast/specimen-detail.html @@ -93,10 +93,10 @@ {% if current_user.is_authenticated %}編輯{% endif %}