Technical blog from Craig Russell.
All images that will be included in my blog posts live in the same directory, Images
, which is a subfolder of my root blog project repo. Once I have an image I want to include in a blog post, I noticed it being a point of friction to copy it to the correct directory and to add the desired image markup to reference it.
The manual steps were the same each time. From the point of having found the image I want to include in Finder:
Images
subdirectoryFinder
to check againRipe for automation! 🍇
The steps automated by this shortcut are:
Image
subdirectory, required for the blogApple Shortcuts can integrate with Finder
so that we can right-click on any image, and invoke our Shortcut, passing in that image as input to our script.
We can configure the shortcut to be available as a “Quick Action”, and configure the acceptable input types to only allow “Images”, as you can see in the screenshot above. For extra laziness, which is always good, you can add a keyboard shortcut.
I dropped back to the command line to make copying the image easier.
With the image in the correct place, the last step is to reference the image using its filename. To streamline this, the image name is copied to the clipboard for easy pasting.
Shortcut available here: add-image-to-blog-post.shortcut (on MacOS device). Open downloaded file, and import into Apple Shortcuts