function render()
 {
     $pic = $aud = $vid = NULL;
     switch ($this->page) {
         case 'homepage':
             $pic = CNImage::load_recent_media_image(0, $this->subject);
             $aud = CNAudio::load_recent_media_audio(0, $this->subject);
             $vid = CNVideo::load_recent_media_video(0, $this->subject);
             break;
         case 'grouppage':
             $pic = CNImage::load_images_for_collection_id((int) $this->gid);
             $aud = CNAudio::load_audios_for_collection_id((int) $this->gid);
             $vid = CNVideo::load_videos_for_collection_id((int) $this->gid);
             break;
         case 'userpage':
             $pic = CNImage::load_user_gallery_images($this->uid, 10, PA::$login_uid);
             $aud = CNAudio::load_user_gallery_audio($this->uid, 10, PA::$login_uid);
             $vid = CNVideo::load_user_gallery_video($this->uid, 10, PA::$login_uid);
             break;
     }
     //even if we got more media, we can display only 6
     $pictures = array();
     $max = count($pic) < 6 ? count($pic) : ($max = 6);
     for ($i = 0; $i < $max; $i++) {
         $pictures[$i] = $pic[$i];
     }
     $audios = array();
     $max = count($aud) < 6 ? count($aud) : ($max = 6);
     for ($i = 0; $i < $max; $i++) {
         $audios[$i] = $aud[$i];
     }
     $videos = array();
     $max = count($vid) < 6 ? count($vid) : ($max = 6);
     for ($i = 0; $i < $max; $i++) {
         $videos[$i] = $vid[$i];
     }
     if (!empty($this->group_details) && (!empty($pictures) || !empty($audios) || !empty($videos))) {
         $this->view_all_url = PA::$url . PA_ROUTE_MEDIA_GALLEY_IMAGES . "/view=groups_media&gid=" . (int) $this->group_details->collection_id;
     }
     $gallery = array('images' => $pictures, 'audios' => $audios, 'videos' => $videos);
     $this->links = $gallery;
     $this->inner_HTML = $this->generate_inner_html($this->links);
     if (empty($gallery['images']) && empty($gallery['audios']) && empty($gallery['videos'])) {
         $this->height = 70;
         $this->view_all_url = '';
     } else {
         $this->height = 260;
     }
     $content = parent::render();
     return $content;
 }