Skip to content

Commit

Permalink
fix: about image sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
moogoo78 committed Aug 28, 2024
1 parent f532570 commit fe83a30
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
9 changes: 5 additions & 4 deletions app/blueprints/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 9 additions & 6 deletions app/models/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,19 +965,22 @@ 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)
# id_ = f'{accession_number_int:06}'
# 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
Expand Down
6 changes: 3 additions & 3 deletions app/templates/sites/hast/specimen-detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@
{% if current_user.is_authenticated %}<a class="uk-link-muted" href="{{ url_for('admin.modify_frontend_collection_record', collection_id=entity.record.collection_id, record_id=entity.record.id ) }}" target="_blank">編輯</a>{% endif %}
<div class="uk-child-width-1-2" uk-grid>
<div>{# left #}
{% with image_url = entity.get_image('_l') %}{# TODO: x #}
{% with image_url = entity.get_image('l') %}{# TODO: x #}
{% if image_url %}
<img width="480" height="480" alt="{{ entity }}" src="{{ entity.get_image('_l') }}">

<img width="480" height="480" alt="{{ entity }}" src="{{ image_url }}">
更大解析度: <a target="_blank" href="{{ image_url|replace('-l', '-x') }}">1365x2048 pixels</a> | <a target="_blank" href="{{ image_url|replace('-l', '-o') }}">2731x4096 pixels</a>
{% endif %}
{% endwith %}
{#
Expand Down

0 comments on commit fe83a30

Please sign in to comment.