Creating data: URIs in a Drafts action

md2pptx can now do useful things with data: URIs. Drafts has been able to for a long time.

I’d like to write an action that was useful in converting images to data: URIs.

The one thing that looks useful, other than writing something myself, is this: The FileReader API. The resulting data: URI would then be pasted with surrounding []( ... ) and pasted into the current draft.

I think I can cajole FileReader into fetching a graphic from the web and converting it - with readAsDataURL(). But that won’t work for files on macOS and I’ve no idea what is useful on iOS or iPadOS.

Thoughts? Experiences?

I’d really like to create a useful action.

I think that this is the same as a question I asked on the Slack channel earlier this year.

This is why I ended up rolling shortcut and shell script solutions for this preview solution.

But the latest preview features in beta allow rendering of locally stored images, so maybe you could utilise files in that location to be converted to base64 via the preview? Alternatively, you could potentially reuse the solutions in my post and trigger them from an action.

1 Like


My hope is that users could point at a URL or at a local file - on Mac - or something - on iOS - to pull in the graphic and render it as a data: URI. It’s not the web-based stuff that’s troublesome, of course.

I wonder if I can make a Preview nearly invisible. But I suppose a method might be to display the graphic in the Preview with a button called “Make data: URI” or somesuch.

That was what I was wondering. I don’t see any other option right now without a new file read function.