I think there is no way to customize the markdown link in the import images to group options so that when you paste an image you always get the image name in the link, ie
![CleanShot 2022-09-02 at 09.40.06](assets/CleanShot%202022-09-02%20at%2009.40.06.png)
this is ugly when rendered, as I dont want to see the Cleanshot.. name but just the image. so I want this
That can be easily scripted by changing the plainText property of the file accordingly. In JavaScript, you’d used record.plainText = record.plainText.replaceAll(/!\[.*?\]/g,"![]");
But I’m wondering what exactly you’re seeing with this kind of image link. According to the MMD specification, the text should be used in the alt attribute of the img element. And that’s not something that should appear “ugly” but only visible at all if the image is not found.
as you can see if there is a file name (in the [] section of the link) then naturally Devonthink presents the image name below the image. I want too just see the image. does that make sense?
thx for the JS snippet. where would I use it though? do I create a smart rule in Devonthink to auto launch the JS code each time a link is pasted? do I use Keyboard Maestro ?
Now I see – you’re using images outside of paragraphs. Those are converted to figure elements, and the string in brackets is put into the figcaption element. That’s actually as per the MMD specification: MultiMarkdown User's Guide
And it makes, I’m sorry, perfect sense from the standpoint of semantics, accessibility and usability of the resulting HTML (and that’s what we’re talking about). The caption should convey what the figure is about (as should the alt attribute in the case of an img element). So, having an emptyfigcaption goes against the semantics, and having an empty alt attribute goes against the accessibility of the HTML document.
If you still insist
check the manual on how to write an internal JavaScript script for execution in a smart rule
or search for onperformsmartrule in the forum to see numerous examples
As to how to run the code: since there’s no “on pasting link” event in the smart rule triggers, using a KM macro might be an alternative (outside a smart rule, of course). Or, perhaps, following the HTML rules and providing meaningful text there.
that worked nicely. I wonder if its possible to add a feature request to haver an option to do this automatically when creating the link? (ie allow an empty name when I paste the image and the link is created)