Site icon WP Smith

Get All Images Taken with a Specific Camera: How to Query Attachments' Meta Data in WordPress

Recently, I became curious about wp_generate_attachment_metadata() & wp_update_attachment_metadata() which should be used in conjunction with wp_insert_attachment().

wp_generate_attachment_metadata() generates the following array:

The most curious about this was image_meta which is generated by wp_read_image_metadata().

So I then wondered if one could query the posts and pull all posts that have a specific camera or specific shutter speed. The answer is YES!