/// <summary>
        /// Gets the image link.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <returns></returns>
        public string JustTheImageWebsize(Media media)
        {
            MediaFile thumbnail = media.GetImageByPhotoType(PhotoType.Thumbnail);
            MediaFile websize = media.GetImageByPhotoType(PhotoType.Websize);

            const string linkFormat = "<a class=\"popupimage\" href=\"{0}\" name=\"{4}\" title=\"{1}\"><img src=\"{2}\" alt=\"{3}\" /></a>";
            string link = string.Format(linkFormat,
                                        UrlService.CreateImageUrlUsingCloudUrl(media.Owner.Username, websize.FilePath),
                                        media.Title,
                                       UrlService.CreateImageUrlUsingCloudUrl(media.Owner.Username, thumbnail.FilePath),
                                        media.Description, media.MediaId);

            return link;
        }
        /// <summary>
        /// Gets the image link.
        /// </summary>
        /// <param name="set">The set.</param>
        /// <param name="media">The media.</param>
        /// <returns></returns>
        public static string GetImageLink(string set, Media media)
        {
            MediaFile thumbnail = media.GetImageByPhotoType(PhotoType.Thumbnail);
            MediaFile websize = media.GetImageByPhotoType(PhotoType.Websize);
            IUserUrlService userUrlService = GetUserUrlService();

            const string linkFormat = "<a id=\"{4}\" class=\"showimage lightbox\" name=\"{3}\" rel=\"{2}\" href=\"{5}\" title=\"{1}\"><img src=\"{0}\" alt=\"{1}\" /></a>";
            string link = string.Format(linkFormat,
                                        userUrlService.CreateImageUrlUsingCloudUrl(media.Owner.Username, thumbnail.FilePath),
                                        media.Title,
                                        userUrlService.CreateImageUrlUsingCloudUrl(media.Owner.Username, websize.FilePath),
                                        media.MediaId,
                                        media.Owner.Username,
                                        userUrlService.UserUrl(media.Owner.Username, "photos/show/" + set + "/#/photo/" + media.MediaId));

            return link;
        }
        /// <summary>
        /// Gets the image link.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <returns></returns>
        public string GetImageLink(Media media)
        {
            Func<string, string> title =
                s => (string.IsNullOrEmpty(media.Title)
                     ? string.Empty
                     : string.Format("title=\"{0} - {1} {2}\"", media.Title, media.Owner.FirstName, media.Owner.LastName));

            MediaFile thumbnail = media.GetImageByPhotoType(PhotoType.Thumbnail);
            MediaFile websize = media.GetImageByPhotoType(PhotoType.Websize);
            const string linkFormat = "<a class=\"{5}\" id=\"{7}\" name=\"{6}\" rel=\"{0}\" href=\"{8}\" {1} ><img src=\"{2}\" alt=\"{3}\" {4} /></a>";
            string link = string.Format(linkFormat,
                UrlService.CreateImageUrl(media.Owner.Username, websize.FilePath),
                title(media.Title),
                UrlService.CreateImageUrl(media.Owner.Username, thumbnail.FilePath),
                media.Title,
                title(media.Title),
                "lightbox showimage",
                media.MediaId,
                media.Owner.Username,
                UrlService.UserUrl(media.Owner.Username, "photos/show/#/photo/" + media.MediaId));

            return link;
        }
        /// <summary>
        /// Grayscales the specified id.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <returns></returns>
        public ActionResult Grayscale(Media media)
        {
            MediaFile thumbnail = media.GetImageByPhotoType(PhotoType.Thumbnail);
            byte[] fileBytes = _imageService.GetFileBytes(thumbnail, Owner);
            string contentType = _imageService.GetContentType(thumbnail);
            Bitmap bitmap = _imageConverter.ConvertByteArrayToBitmap(fileBytes);
            Bitmap grayScale = _imageConverter.ConvertToGrayScale(bitmap);

            byte[] grayScaleBytes = _imageConverter.ConvertBitmaptoBytes(grayScale, ImageFormat.Jpeg);

            bitmap.Dispose();
            grayScale.Dispose();

            return File(grayScaleBytes, contentType);
        }
        /// <summary>
        /// Gets the image link.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <param name="cssClass">The CSS class.</param>
        /// <param name="set">The set.</param>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public static string GetImageDetailLinkForFirst(Media media, string cssClass, string set, PhotoType type)
        {
            IUserUrlService userUrlService = GetUserUrlService();
            Func<string, string> title =
                s => (string.IsNullOrEmpty(media.Title)
                     ? string.Empty
                     : string.Format("title=\"{0} - {1} {2}\"", media.Title, media.Owner.FirstName, media.Owner.LastName));

            MediaFile thumbnail = media.GetImageByPhotoType(type);
            const string linkFormat = "<a class=\"{5} lightbox\" name=\"{6}\"  href=\"{0}\" {1} ><img src=\"{2}\" alt=\"{3}\" {4} /></a>";
            string link = string.Format(linkFormat,
                userUrlService.UserUrl(media.Owner.Username, "photos/show/" + set + "/#/photo/" + media.MediaId),
                title(media.Title),
                userUrlService.CreateImageUrl(media.Owner.Username, thumbnail.FilePath),
                media.Title,
                title(media.Title),
                cssClass,
                media.MediaId);

            return link;
        }
 /// <summary>
 /// Gets the image SRC.
 /// </summary>
 /// <returns></returns>
 public string GetImageSrc(Media media, PhotoType type)
 {
     MediaFile webSize = media.GetImageByPhotoType(type);
     string url = UrlService.CreateImageUrl(media.Owner.Username, webSize.FilePath);
     return url;
 }
        /// <summary>
        /// Gets the image HTML.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <returns></returns>
        public string GetImageHtml(Media media)
        {
            const string htmlFormat = @"<img alt=""{0}"" id=""image"" src=""{1}"">";

            MediaFile mediaFile = media.GetImageByPhotoType(PhotoType.Websize);
            return string.Format(htmlFormat, media.Title, UrlService.CreateImageUrl(mediaFile.FilePath));
        }
 /// <summary>
 /// Fullsizes the specified media id.
 /// </summary>
 /// <param name="media">The media.</param>
 /// <returns></returns>
 public ActionResult Small(Media media)
 {
     MediaFile fullsizeFile = media.GetImageByPhotoType(PhotoType.Thumbnail);
     return GetFile(fullsizeFile);
 }
 /// <summary>
 /// Fullsizes the specified media id.
 /// </summary>
 /// <param name="media">The media.</param>
 /// <returns></returns>
 public ActionResult Medium(Media media)
 {
     MediaFile fullsizeFile = media.GetImageByPhotoType(PhotoType.Websize);
     return GetFile(fullsizeFile);
 }
        /// <summary>
        /// Gets the media.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <returns></returns>
        public JsonResult GetDetails(Media media)
        {
            MediaFile file = media.GetImageByPhotoType(PhotoType.Websize);
            string imageSrc = UrlService.CreateImageUrl(file.FilePath);
            string details = GetDetailSection(media, Authorization.IsOwner);

            Resizer resizer = new Resizer();
            resizer.Resize(file.Width, file.Height, Authorization.Owner.Settings.WebViewMaxWidth, Authorization.Owner.Settings.WebViewMaxHeight);

            return Json(new { imageSrc, media.Title, media.Description, details, Authorization.Owner.DisplayName, resizer.Width, resizer.Height }, "application/json");
        }
 /// <summary>
 /// Fullsizes the specified media id.
 /// </summary>
 /// <param name="media">The media.</param>
 /// <returns></returns>
 public ActionResult Fullsize(Media media)
 {
     MediaFile fullsizeFile = media.GetImageByPhotoType(PhotoType.Original);
     return GetFile(fullsizeFile);
 }
        /// <summary>
        /// Gets the random album image.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <returns></returns>
        private string GetRandomAlbumImage(Media media)
        {
            string randomImageLink = UrlService.CreateRootUrl("content/images/nophotosfound.png");

            if (media != null)
            {
                string filePath = media.GetImageByPhotoType(PhotoType.Thumbnail).FilePath;

                if (!string.IsNullOrEmpty(filePath))
                {
                    randomImageLink = UrlService.CreateImageUrl(filePath);
                }

            }

            return randomImageLink;
        }
        /// <summary>
        /// Gets the image link.
        /// </summary>
        /// <param name="media">The media.</param>
        /// <returns></returns>
        public static string GetThumbnailImage(Media media)
        {
            string link = string.Empty;

            if (media != null)
            {
                IUserUrlService userUrlService = GetUserUrlService();

                MediaFile thumbnail = media.GetImageByPhotoType(PhotoType.Thumbnail);
                const string linkFormat = "<img src=\"{0}\" alt=\"{1}\" /></a>";
                link = string.Format(linkFormat, userUrlService.CreateImageUrl(media.Owner.Username, thumbnail.FilePath), media.Description);
            }

            return link;
        }