• Thanks for your plugin – saving my day!
    I am writing a plugin and the user can upload files via the media uploader. I would like that a media-tag should automatically be assigned to upload depending on my plugin page.

    Here is the hack I used in mediatags_admin.php @#488

    $media_tags_default=(isset($_GET["media-tags-default"]) && ($_GET["tab"]=="type") || !isset($_GET["type"])) ? $_GET["media-tags-default"] : ""; //<- probably not used!!
            if(!$media_tags_default){
              $qs=  parse_url($_SERVER["HTTP_REFERER"], PHP_URL_QUERY);
              parse_str($qs, $get_array);
              if(isset($get_array["media-tags-default"]) &&(!isset($get_array["type"]) || $get_array["tab"]=="type" )){
                $media_tags_default=$get_array["media-tags-default"];
              }

    and then injected $media_tags_default a few lines later

    $form_fields['media-meta'] = array(
           		'label' => __('Media-Tags:', MEDIA_TAGS_I18N_DOMAIN),
       			'input' => 'html',
       			'html' => "<input type='text' name='attachments[$post->ID][media_tags_input]'
    				id='attachments[$post->ID][media_tags_input]'
           			size='50' value='<strong>$media_tags_default</strong>' />
    				$post_media_tags_fields "
    		);

    Basically as uploads are handled via ajax to async.php I look at referer to get default tag. I also check the tab=type so it should only inject on upload page.
    usage: to set default tab for upload – /wp-admin/media-upload.php?&tab=type&media-default-tags=my_default_tag

    It seems to work! Would be great if you can include feature in future version.
    Also the media-tags are not getting included in wordpress 3.5 – USING BACKWARDS COMPATIBLE media-upload.php

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

  • The topic ‘[Suggestion] Setting parameter to allow default tag for upload’ is closed to new replies.