mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-24 03:43:42 -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 = source_image_response.content
|
||||||
source_image_response.close()
|
source_image_response.close()
|
||||||
|
|
||||||
file_ext = os.path.splitext(file.source_url)[1]
|
content_type_parts = content_type.split('/')
|
||||||
# fall back to parsing the http content type if the url does not contain a file extension
|
if content_type_parts:
|
||||||
if file_ext == '':
|
file_ext = '.' + content_type_parts[-1]
|
||||||
content_type_parts = content_type.split('/')
|
if file_ext == '.jpeg':
|
||||||
if content_type_parts:
|
file_ext = '.jpg'
|
||||||
file_ext = '.' + content_type_parts[-1]
|
|
||||||
else:
|
else:
|
||||||
|
file_ext = os.path.splitext(file.source_url)[1]
|
||||||
file_ext = file_ext.replace('%3f', '?') # sometimes urls are not decoded properly
|
file_ext = file_ext.replace('%3f', '?') # sometimes urls are not decoded properly
|
||||||
if '?' in file_ext:
|
if '?' in file_ext:
|
||||||
file_ext = file_ext.split('?')[0]
|
file_ext = file_ext.split('?')[0]
|
||||||
|
|
Loading…
Add table
Reference in a new issue