• Is there a function or anything I can call to get a list of all media files in the library or search them based on some attribute?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter RobotHero

    (@robothero)

    The obvious thing would be to search for post_type=’attachment’ but every media file has three entries in wp_posts plus the wp_postmeta data _wp_attached_file, wpml_media_processed, _wp_attachment_metadata so I would assume there’s some proper channels I should go through that makes sense of all that.

    Moderator bcworkz

    (@bcworkz)

    Three entries? I’ve not experienced that. I only see one for each image in my DB! In any case, that’s what you have. There must be something unique about one of the fields that identifies one as more “official” than the others. Post status perhaps? It may even be one of the post meta fields. It doesn’t matter much what’s unique as long as something consistently is. If all else fails, query for all attachment post types where guid is distinct. You’ll get one attachment for each image, even if the record returned isn’t the “official” one.

    Thread Starter RobotHero

    (@robothero)

    Okay, it turns out the three entries were being created by another plugin.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Media Library list?’ is closed to new replies.