5th November 2019

I write a lot of my blog posts on my iPad using iA Writer, and because it is mainly a text editor, it doesn’t support adding photos directly into a document. This makes it slightly more cumbersome for myself when I’m trying to include an image in a post, so I’d have to go to the web interface of my blog, upload an image manually, and then copy the URL.

However, it recently came to my mind that I could probably automate this process. And of course, that would be with the Shortcuts app.

So I made a simple Shortcut that can be run from the Share Sheet, accepting only images.

Then because I simply want to upload it to my WordPress blog (I have no separate CDN for images), I attempted to use the “Post to WordPress” action. Which I only just discovered can upload media, along with posts and pages.

And just like when you upload a new post using that action, the result is the URL of the uploaded post/page/media.

Although the URL that was returned wasn’t exactly the one I was looking for. I was expecting the absolute URL for the image that was uploaded. But instead, it was the URL of a kind of “preview” page, which is essentially the same template used for a blog post, except the content is the image that was uploaded.

This stumped me, and I was considering giving up with the Shortcut at this point. But I realised that Shortcuts can handle articles on websites pretty well.

So I played around with the various actions that dealt with articles and found a very simple solution to extract the image URL. It turns out, in the weird media post (that’s not actually uploaded as a blog post 🤨) has the uploaded image set as being the featured image.

That meant that I could extract that using the “Get Details of Article” action, right after the “Get Article using Safari Reader” action, and then select to get the “Main Image URL”. And it worked perfectly.

So with the fundamental work done, I added an “Ask for Input” action at the beginning, to extract the title of the media. And also a “Text” block, to use the title and image URL and format it as Markdown so it can then be quickly copied and pasted into a document in iA Writer.


So after all of that talking, I’m sure you would like to see what the Shortcut actually looks like:

Upload Image To Blog Shortcut Screenshot

Download the Upload Image To Blog Shortcut

Hopefully either the resulting Shortcut can be useful to other people, or at least my thought process behind it, as no matter how good you think you know Shortcuts, it also seems to surprise you.

17th May 2019

Since the start of this year, I’ve been writing a daily journal on a separate part of this blog.

After I started writing the entries, I realised I didn’t want the boring task of creating the file in a specific directory, and creating the same title/header over and over again. So I added a tiny bit of automation.

Things Task

iVBORw0KGgoAAAANSUhEUgAABS0AAAo4CAYAAAC8JoK+AAABgmlDQ1BzUkdCIElFQzYxOTY2LTIu-2.PNG

The first thing I did was to set up a task in Things, that repeated every day, simply to tell me to write my journal. After a while, I noticed that I would sometimes get very close to 12 before remembering about it. So I added a reminder for 11 pm, which gives me a bit of time to delay and still get it done in time.

Journal Template Shortcut

To take the hassle out of creating the initial file, I created a relatively small shortcut that creates the template and opens it in iA Writer.

I have a specific directory for my journal entries, and this keeps them all in one place.

It also uses the current date to create the filename and the heading for the post.

From there, it opens iA Writer, so I can jot down what I did in that day. And it’s ready to be published

You can download my “Journal Template” shortcut for reference.

Linking the Shortcut to the Things Task

Image.PNG

While Things is useful enough to help me remember I need to write my entry, and the shortcut helps to create the initial file, I also linked these together.

I did that by adding a custom URL into the body of the Things task, so whenever it notified me, I could tap on the task and then on the link. It would then launch the shortcut, and lets me immediately start writing.

It also allows me to not starting right away, as sometimes I’m not in the best place to do it, or I just want to put it off a bit longer.

The url is quite simple, and is in the following format:

shortcuts://run-shortcut?name={name}

{name} is the name of the Shortcut, but URL encoded. You may be able to work this out yourself, but my app Text Case can also do this for you.

More Automation

After I finish writing my journal entry for the day, I then publish it to my blog. I use the built-in “New Draft on WordPress” share extension, which then opens the draft in Safari where I can add the category, and publish.

It’s a reasonably quick task, but something else I plan on automating. So in the near future, I will be creating another shortcut, that can take the latest journal entry and publish it to my blog using the specific category and time I like.