-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix(study-options): load local images in deck description #19912
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
base: main
Are you sure you want to change the base?
Conversation
|
Pretty sure the copyright header isn't the same as the one we follow i.e. it's missing the line with your name and email |
criticalAY
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not the solution I expect,
- What happens when collection is synced I don't think the media is gonna be there afterwards
- Where are you actually saving the image, I can just clean my unused media and voila
|
Sorry about that, I completely overlooked those points. |
5ff72af to
5062894
Compare
|
Fixed the copyright header, |
|
@Akira2206 No that is becuase it is unused you copied it from a card and then discarded that card, so it makes it unused and user is free to remove it from their device, even after sync it will be broken in Desktop or even when you will fetch it again in AnkiDroid |
|
@criticalAY I get the concern about the file being deleted. But looking at
Since the function takes no arguments, I can't pass a list of deck description images to mark them as used. The determination of what is "Used" happens entirely inside the backend. Given that I can't modify that behavior from here, and that this change brings parity with Desktop (which renders the image even if unused), is this acceptable? |
|
Media used in the deck description should have a leading |
david-allison
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great first step, thanks!!
I don't think this handles the issue you raised where a large number of images crashed the app, causing a denial of service.
AnkiDroid/src/main/java/com/ichi2/anki/DeckDescriptionImageGetter.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/DeckDescriptionImageGetter.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/DeckDescriptionImageGetter.kt
Outdated
Show resolved
Hide resolved
| val wrapper = LevelListDrawable() | ||
| val empty = Color.TRANSPARENT.toDrawable() | ||
| wrapper.addLevel(0, 0, empty) | ||
| wrapper.setBounds(0, 0, 0, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this match the past rendering of a https:// image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, previously it displayed a blue square placeholder. Is the transparent behaviour fine or should I revert it to showing the square?
AnkiDroid/src/main/java/com/ichi2/anki/DeckDescriptionImageGetter.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/DeckDescriptionImageGetter.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/DeckDescriptionImageGetter.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/DeckDescriptionImageGetter.kt
Outdated
Show resolved
Hide resolved
| * You should have received a copy of the GNU General Public License along with | ||
| * this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
| package com.ichi2.anki |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs a better location
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the file to com.ichi2.ui, hope it's correct?
|
@david-allison what is the outcome for this, I am more interested in knowing how is this usable to the user? After sync? And why would we want to store image for desc. in |
5062894 to
b088ab1
Compare
Thankyou! I have made the requested changes.
I wasn't aware of this convention. I am assuming we rely on the user to manually rename their files with an underscore in the deck description? |



Purpose / Description
Enables the loading of local images within the Deck Description (Study Options screen).
Currently, the standard
Html.fromHtmlimplementation does not know how to resolve relative paths against thecollection.mediadirectory. This PR implements a custom image getter to locate and display these local files correctly.Note: Remote images (http/https) are explicitly ignored to prioritize security and user privacy
Fixes
Approach
DeckDescriptionImageGetterimplementingHtml.ImageGettercollection.mediadirectoryHow Has This Been Tested?
Manual Verification Steps:
<img src="...">tagPerformance Note
Tested successfully with typical usage scenarios (5-10 images in the description) with no UI lag
Automated Tests:
./gradlew jacocoUnitTestReport(passed)./gradlew ktlintFormat(passed)2025-12-23.at.21.38.35.mp4
Checklist