Skip to content

[ACTV-270] Sync deck media referenced in templates#1242

Merged
abdnh merged 7 commits intomainfrom
ACTV-270
Feb 12, 2026
Merged

[ACTV-270] Sync deck media referenced in templates#1242
abdnh merged 7 commits intomainfrom
ACTV-270

Conversation

@abdnh
Copy link
Contributor

@abdnh abdnh commented Feb 4, 2026

Related issues

Proposed changes

Media files referenced in note type templates were not detected by the add-on and synced when users upload decks.

How to reproduce

  1. Check out https://github.com/AnkiHubSoftware/ankihub/pull/3351 in the web app.
  2. Create a note type with an image referenced in the front/back/styling template (Tools > Manage Note types), e.g. <img src="_foo.png">.
  3. Create a new deck with some notes using the template and upload it to AnkiHub.
  4. Switch to a separate Anki profile, log in to your AnkiHub account and confirm the image shows when reviewing cards. Note that you need to restart Anki completely because Anki might show you the same image cached from the first profile.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @abdnh, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue where media files embedded within Anki note type templates were not being detected and synchronized when users uploaded decks. The changes extend the media detection capabilities to parse note type CSS and template fields, ensuring that all referenced media, regardless of whether it's in note fields or note type definitions, is correctly identified and included in the synchronization process. This improves the robustness and completeness of deck media management.

Highlights

  • Enhanced Media Detection: The system now correctly identifies and syncs media files referenced within Anki note type templates (CSS, front, and back templates), addressing a previous oversight where these files were not included during deck uploads.
  • New Utility Function: A new function, get_media_names_from_notetype, has been introduced to specifically extract local media references from a given note type's styling (CSS) and template fields (question and answer formats).
  • Integration into Media Sync Logic: The core media synchronization logic in media_sync.py has been updated to leverage the new get_media_names_from_notetype function, ensuring that all relevant media from note types are comprehensively included when determining media to be synced for a deck.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • ankihub/ankihub_client/models.py
    • Modified get_media_names_from_notes_data to include media references from note types associated with the given notes, in addition to the notes themselves.
    • Added a new function get_media_names_from_notetype which extracts local media names from the CSS, question format (qfmt), and answer format (afmt) of a specified Anki note type.
  • ankihub/gui/media_sync.py
    • Imported the newly added get_media_names_from_notetype function.
    • Updated the _media_referenced_by_notes method to collect unique note type IDs from the notes and then use get_media_names_from_notetype to gather all media referenced within these note types, adding them to the overall set of media names for synchronization.
Activity
  • No human activity (comments, reviews, etc.) has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@abdnh abdnh force-pushed the ACTV-270 branch 2 times, most recently from 0e13ca9 to cdffb01 Compare February 5, 2026 11:29
@abdnh abdnh marked this pull request as ready for review February 6, 2026 12:51
@abdnh abdnh merged commit d2619e4 into main Feb 12, 2026
8 checks passed
@abdnh abdnh deleted the ACTV-270 branch February 12, 2026 14:28
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

Comments