Hello, im using AJT Media Converter / WebP, AVIF to compress images with AVIF, but image occlusion “paste from clipboard” bypasses the add-on and paste jpg.
Not sure if an add-on fix is possible, but another workaround would be to unhide the image field in the editor
Image Occlusion enhanced is an alternative, you have to manually edit every card with the compressed image, while the built-in requires changing one
Its more troublesome than simply unhiding the image field tbh, but ig it would work, but instead of changing in Anki, the user would require to download the avif image and open the file app to change it
For instance the workflow on basic or cloze is:
Paste image in field > AJT compress and convert image > outputs AVIF
AJT Media Converter uses gui_hooks.editor_will_process_mime. If it finds an image file in the mime data, it converts it to webp or avif depending on the settings.
I’ve heard about image occlusion before. If I’m right, it is when you have an image on the front of a flashcard and there’s a hidden piece that you need to recall. Are you talking about this addon? If so, it is possible that the add-on uses a different code path from what AJT Media Converter is designed to work with. I haven’t used it myself. If you teach me how to use it, I might be able to figure out why it doesn’t work.
Thanks, found it. Didn’t know Anki had such a feature lol. Is it intended to be used by regular users? Judging by how confusing it is, maybe it’s a hidden feature, and it’s not ready yet. However, if you press "Edit" > "AJT Media Converter: Bulk convert" then it converts the image correctly, so it’s not completely broken. The note editor is still broken though. I can only see the image in the Editor, and all fields are completely hidden. If I press “Fields”, I can see that the note has 5 fields, but none of them are shown in the Editor.
Here’s a script that can help you see the contents of a note (use the debug console to run it):
from aqt import mw
note = mw.col.get_note(1234567890123)
for field in note.keys():
print(f"{field}: {note[field]}")
Apparently, when you press “paste image from clipboard”, Anki runs the function select_image_from_clipboard_and_occlude() and doesn’t call gui_hooks.editor_will_process_mime(). So I’m assuming the hook should be called after this line, but it is not:
And when you press “select image”, Anki runs select_image_and_occlude().
There’s a method setup_mask_editor(). I think if AJT Media Converter wraps it, it could be sufficient to intercept and convert images before they’re shown.