Anyone came up with a smart way to automate removing the image title in Devonthink paste image MD link?

hi all

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

![](assets/CleanShot%202022-09-02%20at%2009.40.06.png)

anyone has any automated solution to this (or is this going to be an option in the near future?)

thx!

Z

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.

thx @chrillek !

here is what I mean visually

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 ?

thx!!

Z

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 empty figcaption 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
  • or visit <marketing>Scripting with JXA | JavaScript for Automation (JXA) </marketing> for more information on JavaScript on macOS (not only in the context of DT)

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.

Remove Image Captions.workflow.zip (8.0 KB)

Unzip this and double-click the resulting file.
Select a Markdown file, then choose DEVONthink 3 > Services > Remove Image Captions.

How’s that work for you?

thx @BLUEFROG !!

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)

thx again

Z

You’re welcome.
Development would have to assess this request.