How to use taxonomy(optional)?


#1

I would like to be able to associate an image with a custom taxonomy term. (I would like to input at the time of upload.)

I read 'Upload Endpoint' and tried the following.

However, it does not go into DB (wp_terms,wp_term_relationships,wp_term_taxonomy). The upload of the picture operated normally and other object (title,description..etc) is contained.

How to use taxonomy(optional) ?? or Can it be made to operate by other methods?

like this, http://rtcamp.com/groups/rtmedia/forum/topic/edit-custom-fields-for-attachments/

Upload Endpoint: http://rtcamp.com/rtmedia/docs/developer/rtmedia-api/endpoints/upload-endpoint/#doc-taxonomy

Thank you!


Debug info

PHP 5.3.6-13ubuntu3.10 MYSQL 5.1.67 WordPress 3.6 BuddyPress 1.8.1 rtMedia 3.1.1 OS Linux Imagick ImageMagick 6.6.0-4 2012-08-17 Q16 www.imagemagick.org GD 2.0 [php.ini] post_max_size 8M [php.ini] upload_max_filesize 10M [php.ini] memory_limit 256M


#2

@kms - We are working on the documentation and rtMedia still isn't that flexible yet. You would need to add the taxonomy term to the media manually through code. This function could come handy maybe -> http://codex.wordpress.org/Function_Reference/wp_set_object_terms


#3

@joshuaabenazer - Thank you. It operated now.

If the code has become like this, two or more tags will be attached and I will think that it is convenient.

function add_taxonomy ( $attachments, $taxonomies ) {  

    foreach ( $attachments as $id ) {  

        foreach ( $taxonomies as $taxonomy => $terms ) {  
            if ( ! taxonomy_exists ( $taxonomy ) ) {  
                continue;  
            }  

            // Separate our comma separated list into an array  <--add  
            $terms = explode(",", $terms);  
            foreach ($terms as $term) {  
                wp_set_object_terms ( $id, $term, $taxonomy, True);  
            }  
        }  
    }  
}  

#4