I’m a photography nut. I love using my DSLR, I’m mad about film cameras and I use Instagram all the time. I’m also a WordPress user and I have a problem with Instagram: the photos are not preserved on my own site. To fix that I installed the amazing DsgnWrks Instagram Importer plugin and I’ve been using it for years.
While testing WordPress 4.6 beta the plugin stopped working for me. I raised a support topic and I am convinced that my setup has changed. I do not doubt that the problem is mine somehow.
I’m not proficient enough to locate where the break is and I really wanted to share my Instagram photos via my blog. So I created another WordPress account on my photo blog and with my IFTTT account I used this “Instagram to Blog” recipe. That worked, but it loaded the image from Instagram and used the IFTTT URL shortner for link.
I really wanted a copy of my photo on my own server.
I know less about IFTTT recipes than I do the plugin. But I do know how to use WordPress actions and filters so I wrote a small plugin to do the following.
- Via the publish_post action look in the content for Instagram image sources and extract those URLs. The wp_extract_urls function is made for this.
- When found import those into the WordPress Media Library and attach it to the post using media_handle_sideload.
- Make that new attached image the featured image for the post.
- Look for IFTTT short URLs and expand them using a simple function I wrote.
- Once that’s done then publish the post.
You can view the code via this Gist link. I have that saved and activated as a plugin on my photo blog.
This isn’t the ideal approach for me but it works. The IFTTT recipe successfully publishes a post when I submit a photo to my Instagram account. I’m taking that data and scraping images from another web site. Generally speaking that’s not cool but until I find a cleaner way to do it I’ll have to live with it.