Skip to content

Conversation

@miggazElquez
Copy link

When using the "Attach pictures/audio/video" button in the "Browse" window, files with a capitalized extension (e.g. image.JPG) aren't selectable.

Add a variable pics_uppercase with the extensions in upper case to be used when selecting a media.

I modified only the places where pics (the list of supported extensions) was used with the funciton "getFile": on the other places, the text is converted to lowercase before comparing.

I did only handle the pictures, because I don't think I ever saw a audio file with a capitalized extension, while for pictures it is very common (1/3 of the pictures I downloaded for my deck where ".JPG").

@abdnh
Copy link
Collaborator

abdnh commented Dec 24, 2025

This is not a problem on Windows at least. I wonder if this is file-manager-specific or a Qt bug? What's your OS/file manager?

@miggazElquez
Copy link
Author

I think on windows the file system is case insensitive, so it make sense.
I'm on linux/gnome.

@GithubAnon0000
Copy link
Contributor

GithubAnon0000 commented Dec 24, 2025

I thought that this worked for me but after testing it now, I can confirm that the gnome file manager (nautilus) doesn't display file extensions that are upper case (edit: I should clarify: it does display them, but not if used with ankis media filter when trying to open the file); which means test.JPG cannot be selected, but test.jpg can be selected.

(though I have very rarely seen upper case file extensions anyways; I thought that's common only on windows)

Copy link
Contributor

@GithubAnon0000 GithubAnon0000 left a comment

Choose a reason for hiding this comment

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

I can confirm your solution works. But I'm wondering if its better to add the uppercase versions directly to pics = ("jpg", "jpeg", "png", "gif", "svg", "webp", "ico", "avif").

That way, there would be less computations (potentially faster code) and it's clear at a glance that upper case and lower case extensions are being handeled.

Like this:

pics = (
    "jpg", "JPG",
    "jpeg", "JPEG",
    "png", "PNG",
    "gif", "GIF",
    "svg", "SVG",
    "webp", "WEBP",
    "ico", "ICO",
    "avif", "AVIF"
)

And for consistency reasons, we probably should do the same for the audio files as well.

@miggazElquez
Copy link
Author

(though I have very rarely seen upper case file extensions anyways; I thought that's common only on windows)

They are quite frequent on the internet, I found this problem while downloading pictures from wikipedia, I think something around 1/4 or 1/3 of them are upper case.

I can confirm your solution works. But I'm wondering if its better to add the uppercase versions directly to pics = ("jpg", "jpeg", "png", "gif", "svg", "webp", "ico", "avif").

I was wondering about it too, I will change it that way if you prefer.

When using the "Attach pictures/audio/video" button in the "Browse"
window, files with a capitalized extension (e.g. image.JPG) aren't
selectable.

Add the extensions in upper case to the list of supported extensions.
Copy link
Collaborator

@abdnh abdnh left a comment

Choose a reason for hiding this comment

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

I think this is fine for now. For consistency, maybe it makes sense to handle this in getFile() in the future, especially since the Python editor will be deprecated in #4029

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.

3 participants