implemented media_count and improved get_directories and get_thumbnails functions