How to add a category or tag to media at upload time with the browser uploader?

I don’t use WordPress very often… I hope this makes some sense 🙂

Is there a way to sort media files into categories?
I want to give some order to the media that are being uploaded to the website, and ‘attaching’ media to a Post is not cutting it 🙂

Read More

After a quick search, I found these two plugins. Does anyone have any experience with them? Would anyone recommend another route?

Can I add a Category Metabox to attachment?

http://wordpress.org/extend/plugins/media-tags/

Both plugins would add the functionality that I’m after. Perhaps the only grievance is that media ‘tagging’ at upload time doesn’t work with the ‘browser uploader’…

Related posts

Leave a Reply

2 comments

  1. I’ve been using Media Tags plugin with much success – it was very useful for retrieving images belonging to certain page with specific tags with following code:

    $results = get_attachments_by_media_tags(array("media_tags"=>"gallery", "post_parent" => $global_id, "order" => "ASC"));
    

    Of course you can easily tag anything that sits in your media library (I wasn’t even aware that you could tag something during upload time). As for tagging during upload with browser uploader – it might be too much too ask 😉

  2. ok – just created a get_results query which return post/attachment ids that have a certain tag. Not ideal but does the job…

    function get_attachments_by_tag( $tagid='5', $parentID=0 ){ 
        global $wpdb;
    
        $myrows = $wpdb->get_results( "SELECT object_id FROM $wpdb->term_taxonomy 
                        LEFT JOIN $wpdb->term_relationships ON $wpdb->term_taxonomy.term_taxonomy_id=$wpdb->term_relationships.term_taxonomy_id 
                        LEFT JOIN $wpdb->posts ON $wpdb->term_relationships.object_id=$wpdb->posts.id 
                        WHERE $wpdb->term_taxonomy.term_id = '".$tagid."' AND $wpdb->posts.post_parent = '".$parentID."' " );
    
        foreach ( $myrows as $item ) {
            $sc = get_object_vars($item);   
            $pmIDs[] = $sc['object_id'];
        }
    
        return $pmIDs;
    
    }