19 Comments


  1. This is fabulous. I’ve been wanting this for a long time. I hope, if I understand correctly, that I will be able to see if I have an image that isn’t being used at all. If I added an image into a page or post, will it show it’s being used there? Or does it specifically have to be “attached”?
    I always want to see who uploaded it as well. I’m a clean freak and if there’s old images sitting in the library not being used, I want them gone.

    Reply

    1. Some of the things you want are already available in WordPress. If you browse to the WordPress media library and select Unattached, you’ll be able to see which images are not attached to anything.The Uploaded By and Uploaded To information is coming in WordPress 4.0. What I want is the ability to see every post that is using an image. Right now, I can only see the post the image is attached to. There is a disconnect between the two which is what I’m hoping will be solved with improvements to the way post relationships are handled .

      Reply

  2. I would like a search filter: all images set to ‘featured’.

    Sometimes you want to change theme, and the featured image looks stupid. I’ve tried and suggested that but I don’t think they’ve seen it.

    Reply
    1. swissspidy

      Is there a trac ticket for that? Maybe there was an update in the meantime.

      Otherwise, Sergey’s plugin (see his comment below) could be extended to use a filter like this.

      Reply

      1. I’m a somewhat inexperienced user, and I think it was in WordPress.COM I did it, now that I think of it.

        Imported my wp.com blog and now all my photos are unattached. It’s a sad situation.

        I read about the plugin below, but didn’t really get it — how to install it.

        Reply

  3. I can fully relate to the frustration about media management in WordPress.

    Why can’t an image be attached to multiple posts? Because there are functions that return the ID of the “parent” post/page, so they would have to be altered.
    However, it is not like something like this hasn’t been done before. A post can have multiple tags and categories, but an image can’t belong to multiple posts? Pffff…

    Thankfully there is this plugin, which comes in handy from time to time, though it doesn’t really solve the big problem:
    http://wordpress.org/plugins/unattach-and-re-attach-attachments/

    Reply

    1. Holy smokes, the Awesomesauce award goes to you! I’m going to try it out today and let you know how it goes. How do I download the code as a Zip file or plugin?

      Reply
      1. swissspidy

        You should be able to download the raw data and paste it to a new textfile with a .php extension.

        Reply

      2. Thanks! I’ve submitted the plugin to the WordPress.org directory. Once approved, it should be available there.

        Reply

          1. I noticed :) I’m currently testing it. So if this was so easy to accomplish in a plugin, why do you think core doesn’t already do this?


          2. I think it’s plugin territory, for now at least.

            1. A lot of users use a unique image in each post, so they probably don’t need this feature.

            2. Without the API changes discussed in the tickets linked from the article, the plugin has to perform several search queries for each attachment displayed on the current Media Library page (or in the media modal). I’ve made sure the queries are as light as possible, and they work fine in my testing. However, they still might not scale well and can potentially affect performance on large sites with multiple custom image sizes.

  4. dlouwe

    Technically there already is a many-to-many relationship between posts and media items (as far as Featured Images go), but it’s not something inherent to posts in general.

    The trouble is that while media library entries are technically posts, and do act like objects in certain contexts, they’re still largely treated as an analog for a static physical file with some metadata on top. This means that much of the UI is focused on making the file upload process easy and possible on-the-fly, and the metadata is minimized and when possible hidden.

    So, if we want to start treating media library entries more like objects with proper recognition of their many-to-many relationships with posts, I feel like there’d need to be a significant re-thinking of how they are treated in the WP Admin. Otherwise it’s either going to complicate the existing upload process (which would be bad for average users) or result in a disjointed and unintuitive process.

    Reply

  5. This would be wonderful to have. I run a number of sites that share the same image/word doc/pdf across several pages or posts. It is a true pain when one of these documents needs to be updated.

    Reply
  6. aayler

    Hi Jeff, Thanks for the article.

    Have you seen instances where the image details of an attachment that is created in the post not reflect updates to the metadata, say, caption and alt, performed through the media library?

    Is this the correct behavior such that the attachment to the post is particular and can retain its own, distinct metadata apart from the same attachment in the media library? Or is this a bug?

    Thanks again!

    Reply

Leave a Reply