-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Keep the original image file name when it's attached #9116
Comments
Hello! 👋 Thanks for logging this issue. Please remember we are all volunteers here, so some patience may be required before we can get to the issue. Also remember that the fastest way to get resolution on an issue is to propose a change directly, https://github.com/ankidroid/Anki-Android/wiki/Contributing |
That's right Anki Desktop does save images with their original names, Anki Desktop work like this -> |
Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically |
Based on 2.16alpha42, this is what I got: The method which handles selected files is handleSelectImageIntent. It gets the filename correctly, but changes it when running internalizeUri. internalizeUri changes the filename when making a cache image copy with createNewCacheImageFile To keep the filename, it would be necessary to change createNewCacheImageFile to something like: private File createNewCacheImageFile(@NonNull String filename) throws IOException {
File newImage = new File(mAnkiCacheDirectory, filename);
return newImage;
}
// I'm new to Java, suggestions are welcome or create a new method to be used at internalizeUri (which probably is better to avoid breaking other places which uses createNewCacheImageFile). The only caveat with this method change would be drawings file names, which would change from the current My 1st doubt is which approach should be followed to naming drawings, since they aren't on Anki Desktop.
Then, the second step would be checking if a media with that name already exists. Anki desktop does with this function. Ankidroid does it with writeData. The main difference about its behavior it the filename pattern being My 2nd doubt is why the pattern difference? I guess it's just lack of updating, since that part were added 8 years ago, but let me know if is there any specific reason. It should be updated to keep up with Anki Desktop? Finally, ankidroid only handles adding media with same names. If two names are equal, the new one will have a index correctly added to its name. But the field |
Hey @BrayanDSO solving your own issue from nearly a year ago, nice one!! :-) |
Fixing this is what made I start contributing to AnkiDroid, since attaching images is part of my workflow. Back then when I created the issue, I hadn't thought it would be this easy to join a community and start pushing some bits of code. I'm happy I tried to look further into it and started contributing |
Is your feature request related to a problem? Please describe.
Sometimes I want to use the same image in multiple cards. If I know the image file name, I can just type
<img src="imageFileName.extension">
.The problem: When I attach an image with AnkiDroid, it changes the image file name to something like "img9843278434234908", so it's difficult to use my image again.
Describe the solution you'd like
AnkiDroid keeping the original file name, like the Anki Desktop version does.
Additional context
I believe it's somewhat related to #5192
The text was updated successfully, but these errors were encountered: