Something I’ve wanted to see in WordPress for a long time is the ability to determine which posts an image is being used on. WordPress 4.0 is expected to ship by the end of August and contains two subtle changes to image data in the media library. You’ll be able to view the author who uploaded the image and the post parent ID it’s attached to.
I find this information to be useful, especially for multi-author websites. Although you can view the parent post ID the image is attached to, you can’t locate each post the image is used on. It’s important to note the difference between an image attached to a post and using an image already available in the media library.
Why Knowing Where An Image Is Used Comes In Handy
Let’s say I use a featured image for a post and it’s the featured image for several other posts. If I want to change the featured image in one post and have it change in every other post, I can’t. I also can’t change the image for specific posts automatically, it’s either all or nothing. I can’t determine which posts are using the image because WordPress only sees it being used on the parent post. This is due to the attachment relationship.
In other words, the first post the image is attached to is the only information WordPress has on where it’s being used. I could browse to every post and manually change it but my memory isn’t that good and it’s a tedious process.
The History Behind The Dilemma
In trying to figure out why this is, Justin Tadlock pointed out two Trac tickets, 10657 and 14513. Both contain lengthy, technical discussions, on how to add support for many-to-many relationships between posts and attachments in WordPress. Within the discussions, the Posts 2 Posts plugin is commonly referred to as a top-notch plugin that offers this functionality.
Before the Community Summit in October of 2012, Andrew Nacin and a host of other WordPress developers came together to discuss the subject in detail. The ideas brought forth from that conversation are available on the Make.WordPress.com blog and is a potential roadmap for taxonomy meta and post relationships in WordPress.
It’s Possible But Not Worth The Hassle
WordPress automatically renames files if it detects the same name being used in the media library. This means you can’t upload a new image with the same file name to replace it. An alternative method is to use FTP to locate the original file and overwrite it, keeping the same name. The image will change in all posts using it, regardless of the attachment details. You’ll also need to overwrite any images that were resized automatically by WordPress or else they’ll show up instead of the new ones.
After performing all sorts of tests in my local environment for trying to change one image across multiple posts, I’ve decided it’s too much of a hassle. Not being able to manage these relationships in WordPress doesn’t make sense. Ideally, I’d like to be able to determine which posts are using an image and replace that image across all of those posts at the same time. I also wouldn’t mind the flexibility to change an image for certain posts while leaving the others alone.