mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
prefer mime type to avoid having to parse messy urls
This commit is contained in:
parent
4f3a8b1d74
commit
be58f833ef
1 changed files with 6 additions and 6 deletions
|
@ -974,13 +974,13 @@ def make_image_sizes_async(file_id, thumbnail_width, medium_width, directory):
|
|||
source_image = source_image_response.content
|
||||
source_image_response.close()
|
||||
|
||||
file_ext = os.path.splitext(file.source_url)[1]
|
||||
# fall back to parsing the http content type if the url does not contain a file extension
|
||||
if file_ext == '':
|
||||
content_type_parts = content_type.split('/')
|
||||
if content_type_parts:
|
||||
file_ext = '.' + content_type_parts[-1]
|
||||
content_type_parts = content_type.split('/')
|
||||
if content_type_parts:
|
||||
file_ext = '.' + content_type_parts[-1]
|
||||
if file_ext == '.jpeg':
|
||||
file_ext = '.jpg'
|
||||
else:
|
||||
file_ext = os.path.splitext(file.source_url)[1]
|
||||
file_ext = file_ext.replace('%3f', '?') # sometimes urls are not decoded properly
|
||||
if '?' in file_ext:
|
||||
file_ext = file_ext.split('?')[0]
|
||||
|
|
Loading…
Add table
Reference in a new issue