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'm looking for a method to group images in the media library.

I'm developing a photo portfolio site. I have uploaded all the images to the media library I need a way to group the images to make them more manageable.

At the moment I just have a long list of images.

share|improve this question

1 Answer 1

Attachments itself same as posts... so you can think on giving tham meta_values or adding taxonomies to tham. as for me i always used first method... this is a simple example of how this functioonality works...

add_filter("attachment_fields_to_edit", "afields_to_edit",  10, 2);
add_filter("attachment_fields_to_save", "afields_to_save",  10, 2);

   function afields_to_save($post, $attachment){
          $parentPost = get_post($post['post_parent']);       
          /*************************************************************
          // Roles
          *************************************************************/    

          if (isset($_POST['___attachments'][$post['ID']]['type']) 
              && trim($_POST['___attachments'][$post['ID']]['type']) != ""){

                 $type = $_POST['___attachments'][$post['ID']]['type'];
                 update_post_meta($post['ID'],  '_type',  $type);

           } else {

               delete_post_meta($post['ID'],  '_type');

           }
       return $post;
   }

   function afields_to_edit($form_fields, $post){

       $parentPost = get_post($post->post_parent);
      /***********************************************************************
       Roles
      ***********************************************************************/  
      $form_fields["roles"]["label"] = "File Role";
      $form_fields["roles"]["input"] = "html";

      $html .= "<select name='___attachments[".$post->ID."][type]' style='width:95%;'>";
      $html .= "<option value=''>Default Role</option>";

      $roles = apply_filters('roles_sidebar', array(), $post, $parentPost);


      if (is_array($roles) && count($roles) > 0){
          foreach($roles as $key=>$role){
              $html .= "<option value='".$key."' ".$role['select'].">".$role['name']."</option>";
          }
      }
      $html .= "</select>";


      $form_fields["roles"]["html"]  = $html;
      return $form_fields;
 }

I think you can continue work in this way...

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.