Image Publish Shortcut

I’ve mentioned here before that I don’t want to have to remember the mechanics behind things like how post summaries work when writing posts. The same applies to images in my posts – I wrote an image handler shortcode but if I have to remember parameters or manually paste shortcodes in iA Writer as I crank out an article, I’ve failed.

Tech is supposed to seamlessly enable me to write and publish, not stand between me and my site like a high priest demanding complex incantations that require years of practice to master. Like I’ve said before, the whole point of me using an app like iA Writer is because it has the writing experience I want, and I don’t want to have to write text in Hugo templates. The site shouldn’t dictate how I write, it should just put whatever words I dictate on display when I’m done.

So… not content with having the site handle post summaries automagically in the way I prefer without me having to do a damn thing, I also want to do what every Wordpress (and every other CMS) user does, and upload images and put them inline without having to care at all about how it works or adding any extra markup or markdown or marksideways.

Back to the Shortcuts app.

Since I already use Shortcuts to publish blog posts, and even to upload images, it should be relatively trivial to create a shortcut that will replace a line in my post with a generated bit of Hugo markup calling my image shortcode with the correct parameters for the image in question.

Basically what I am going to do is to put “Image x” in locations where I want images, and then when I run my Blog Publish shortcut, it will find them, ask me what images I want for those, and then generate the shortcode markup.

So this:

Image Working Copy

will eventually get replaced with something like this:

{{< img src="/images/wc.png" link="wc.png" width="850" border="1" caption="Working Copy" align="center" >}}

Image Publish shortcut regex to find image locations

All I have to do is choose the image for each corresponding “Image X” line, tell it how I want to resize the image, tell it how wide I want it to appear in the post, choose a file name, a caption, and optionally an alignment and a border size.

Image Publish shortcut image resize menu

My Blog Publish shortcut is currently at 256 actions and it’s getting a bit unwieldy to edit, so I’m going to put this in a separate shortcut. That means I’ll have to pass it a dictionary with the post body text, the image folder url, the site name, and some other info, but then I can also use it for things like putting images into podcast episode show notes from my BubbleSort Publish Podcast shortcut too.

I really wish Shortcuts had a copy/paste mechanism for whole sections of shortcut blocks…