mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
improve thumbnail generation reliability
This commit is contained in:
parent
352e91d5aa
commit
76ca9aa8f4
1 changed files with 9 additions and 1 deletions
|
@ -982,7 +982,15 @@ def make_image_sizes_async(file_id, thumbnail_width, medium_width, directory):
|
|||
|
||||
content_type_parts = content_type.split('/')
|
||||
if content_type_parts:
|
||||
file_ext = '.' + content_type_parts[-1]
|
||||
# content type headers often are just 'image/jpeg' but sometimes 'image/jpeg;charset=utf8'
|
||||
|
||||
# Remove ;charset=whatever
|
||||
main_part = content_type.split(';')[0]
|
||||
|
||||
# Split the main part on the '/' character and take the second part
|
||||
file_ext = '.' + main_part.split('/')[1]
|
||||
file_ext = file_ext.strip() # just to be sure
|
||||
|
||||
if file_ext == '.jpeg':
|
||||
file_ext = '.jpg'
|
||||
else:
|
||||
|
|
Loading…
Add table
Reference in a new issue