Support » Plugin: File Gallery » [Plugin: File Gallery] get all the media tags for the current post?

  • Is there a way to show all the media tags for the current post without defining what they are?
    I’m not great with code, I’ve done things like this with query_posts but I’m not even sure if this is how it’s done with file galleries media tags.

    <?php
    $arguments=array(
    'tags_from' => 'current'
    );?>
    <?php file_gallery_list_tags($arguments);?>

    It’s not outputting anything.

    I’m generally having trouble finding newbie info on how this plugin works, any help appreciated.

    http://wordpress.org/extend/plugins/file-gallery/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Aesqe

    (@aesqe)

    @deepbevel: currently, that function returns only all media tags, but you can use default WordPress functions to get all media tags related to a specific post’s attachments.

    here’s a quick, untested function which should return an array containing all media tags (each as an object, see here: http://codex.wordpress.org/Function_Reference/get_the_terms) related to a post:

    function get_media_tags_for_post( $post_id )
    {
    	global $wpdb;
    
    	$media_tags_list = array();
    	$tags = array();
    
    	$attachment_ids = $wpdb->get_col(
    		$wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent=%d AND post_type='attachment'", $post_id)
    	);
    
    	foreach( (array) $attachment_ids as $aid )
    	{
    		$tags = get_the_terms( $aid, FILE_GALLERY_MEDIA_TAG_NAME );
    		$media_tags_list = array_merge($media_tags_list, $tags);
    	}
    
    	return $media_tags_list;
    }

    I’ll add this function to File Gallery in version 1.7.6.

    Thanks, I had given up on the idea, wouldn’t believe how many plugins and codes I tried to get tags working right on attachment images.
    Anxious to give it another go, I’ll let you know how the code works out for me.

    I forgt, I had already determined the plugin won’t suit my need unless there’s a way to remove the option for authors to create new tags, and only have the option to select from given tags.

    I want to use the media tags as a way for users to put images into given “categories”, but not have access to the all the file gallery options on the post screen, just want the tagging option in the regular media uploader attachment editor.

    My user set up is super simple, each user gets one post, it’s preloaded with [gallery] in a custom field. There’s no visual or html editor, just an inline media uploader. Users just add a title, upload images and publish. They still have access to the image attachment editor so I thought it would be great if they could optionally put each gallery image in a general “category”, like “landscape, portriat, botanical” ect. (it’s for an art group)

    Thanks anyway, otherwise an awesome plugin that I’ll still probably explore in other projects.

    Plugin Author Aesqe

    (@aesqe)

    @deepbevel: I’ll add support for user permissions in one of the future versions of the plugin. Can’t tell you exactly when, but I’ll reply here when the feature is ready 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: File Gallery] get all the media tags for the current post?’ is closed to new replies.