UPDATE 11 Feb 2023:
Good news! I refactored this to work with the Share Sheet and to prompt you for credentials and a media endpoint on the initial setup.
Here is the new link: https://www.icloud.com/shortcuts/cf31d94107e24e5e947a801fb9d8132c
Here is how easy it is to use on macOS.
And here is how easy it is to use on iOS:
Tonight I sat down and figured out something that has been in my head for months: Uploading photos to my WordPress Media Library with an Apple Shortcut. It works on both macOS and iOS.
I use the REST API to upload them to the /wp/v2/media endpoint via a POST request. For authentication I use a username and Application Password that I base64 encode.
Here is the basic workflow:
- Select the photos
- Loop through them and convert them to JPEGs. This is necessary because WordPress does not currently handle HEIC images, the default iOS image format.
- Use a POST request to upload the converted JPEGs to the /wp/v2/media endpoint.
You currently have to run this from Shortcuts.app. Share sheet support does not work on macOS Monterey, so I still have the step in there to pick images from Photos.app. I know they added this in Ventura, but I haven’t upgraded yet. Once I do, I’ll change this to only take images from the Share sheet so you can start in Photos.app rather than Shortcuts. I know share sheet support works on iOS, but since I blog most on my Mac, I wanted to make a shortcut that works in both places.
If you’d like to use this Shortcut, you can get it here: https://www.icloud.com/shortcuts/e473f76d1692444896077ebcdbc4c893
If you use it, you’ll need to make two changes:
- In the Text area at the top, put your WordPress Username and Application Password in this format:
- Application passwords are found under wp-admin -> Users -> your user profile -> Application passwords
- Change the domain from example.com to your website’s domain.