Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 :-)

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

http://wordpress.stackexchange.com/questions/496/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'...

share|improve this question
    
great question... One of the key things which I have been trying to figure out is not only how to attach files to tags AND categories but I am looking for a way to be able to automatically assign uploads for posts within specific post types to a specific category. I wonder why this option does not exist by default... –  NetConstructor.com Sep 20 '10 at 14:10
1  
aei: I made the first plugin you've listed above, I've actually just added a fix to the browser uploading of the WOS Media Categories Plugin now, you can download the latest version of the plugin via this link: suburbia.org.uk/page/projects.html#wos_media_categories –  Rick Curran Nov 1 '10 at 13:40
add comment

2 Answers

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;

}
share|improve this answer
add comment

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 ;)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.