Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement: use file extension if filetype.guess fails #73

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

schmiddim
Copy link

I created a more simple fix for #46
every lib fails with mime type application/octet-stream so it now guesses by extension.

Cheers and thanks for your awesome code!

self.media_ext = os.path.splitext(absolute_path)[-1].replace(".", "")
else:
self.media_ext = ext.extension

def is_image(self):
return True if self.media_ext in ['jpg', 'png', 'gif'] else False
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail on .jpeg filetypes if using the fallback. Could do this:

Suggested change
return True if self.media_ext in ['jpg', 'png', 'gif'] else False
return True if self.media_ext in ['jpg', 'jpeg', 'png', 'gif'] else False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants