Publishing Graphics To Wordpress With Image References In Current Draft

Reminded by this topic on Wordpress, does anyone have code to pick a graphic and post it to a Wordpress blog, returning an image reference in Markdown format? (Emphasising “graphic” as - in my imagination - it isn’t about publishing text.)

I write my blog posts in Drafts. I accept that to preview them I might as well send the graphics to Wordpress ahead of publishing the blog post. The above would remove some of the friction.