Skip to content

Commit

Permalink
fix: HACK images revert to old
Browse files Browse the repository at this point in the history
  • Loading branch information
moogoo78 committed Mar 1, 2024
1 parent 8898f9b commit c8c6f58
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions app/models/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,11 +821,19 @@ def get_annotation(self, type_name='', part=''):

def get_image(self, thumbnail='_s'):
if self.collection_id == 1:
if self.multimedia_objects:
#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)
id_ = f'{accession_number_int:06}'
thumbnail = thumbnail.replace('_', '-')
return f'https://pid.biodiv.tw/ark:/18474/v6cc0ts6j/S_{id_}{thumbnail}.jpg'
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
except:
pass
# TODO, get first cover or other type
#if media := self.multimedia_objects[0]:
# if media.file_url:
Expand Down
2 changes: 1 addition & 1 deletion app/templates/specimen-detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
{% if current_user.is_authenticated %}<a class="uk-link-muted" href="{{ url_for('admin.record_form', 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('_x') %}
{% with image_url = entity.get_image('_l') %}{# TODO: x #}
<a class="uk-inline" href="{{ image_url }}">
{% if image_url %}<img width="480" height="480" alt="{{ entity }}" src="{{ entity.get_image('_l') }}">{% endif %}
</a>
Expand Down

0 comments on commit c8c6f58

Please sign in to comment.