Image filename to field?

Hey all, so I was wondering…
Is it possible to have images associated with a field, say for example eat.jpg to {{Expression}}, if the expression field is that word?
For example: The Expression field is the word Eat and the Image field should grab the expression field and the image from collection.media with the same name.
Thank you all for your help!

This should be easily achievable with a bit of JavaScript in your card template.

I’m wondering though: Why would you want to use a system that is very prone to errors (e.g. typos in the {{Expression}} field) and go through the struggle of renaming your images, when you can just paste the images directly in the editor?

There is also the issue of unused media: Anki will not know which notes the images belong to and count a bunch of them as unused :thinking:

2 Likes

Hey,
Yeah, it’s a pretty stupid system, but in this case it’s pretty straightforward because the Expression field has only ideograms. I fetched all the images from a website and the content is pretty difficult to find, mainly ideogram origin explanations so fetching them all manually is a lot of work.
About the unused media issue, is there any way to make them count?
Thanks for the help

Instead of inserting the images with JavaScript during review, you could batch-insert them into your notes the following way:

As long as the words in the {{Expression}} field are all lowercase, you could create a custom copy with the Advanced Copy Fields add-on like this:

How to get to the screen shown below

image

image

image

Example:

image

Use the following template:

<img src="{{Expression}}.jpg">

If they start with an uppercase letter, then you would first have to batch-lowercase them somehow with an external tool (Anki’s RegEx engine doesn’t allow for lowercase conversion, I think).

2 Likes

Works wonderfully! Thanks so much :slight_smile: