/// <summary>
        /// Gets the edit details.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public ActionResult GetEditDetails(int id)
        {
            Media     media    = _mediaRepository.RetrieveByPrimaryKeyAndUserId(id, Authorization.Owner.Id);
            MediaFile file     = media.GetImageByPhotoType(PhotoType.Websize);
            string    imageUrl = UrlService.CreateImageUrl(file.FilePath);
            var       data     = new
            {
                ImageUrl = imageUrl,
                media.Title,
                Story = media.Description,
                media.Year,
                media.Month,
                media.Day,
                LocationName = (media.Location.LocationName ?? string.Empty),
                Latitude     = (media.Location.Latitude == 0 ? string.Empty : media.Location.Latitude.ToString()),
                Longitude    = (media.Location.Longitude == 0 ? string.Empty : media.Location.Longitude.ToString()),
                Zoom         = (media.Location.Zoom == 0 ? string.Empty : media.Location.Zoom.ToString()),
                media.Location.MapTypeId,
                Tags = (media.Tags == "untagged" ? string.Empty : media.Tags),
                media.BelongsToAlbums,
                Status = media.Status.ToString()
            };

            return(Json(data));
        }
        /// <summary>
        /// Generates the image links.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="medias">The medias.</param>
        /// <returns></returns>
        private string GenerateImageLinks(string key, IEnumerable <Media> medias)
        {
            if (medias == null)
            {
                throw new ArgumentNullException("medias");
            }

            //0 - media id
            //1 - fullsize media
            //2 - title of media
            //3 - thumbnail image
            const string format = @"<li>
					 <span class=""image"">
						<a name=""{0}"" rel=""{1}"" href=""{4}"" class=""showimage"" title=""{2}""> 
							<img src=""{3}"" alt=""{2}"" /> 
						</a> 
					  </span> 
					</li>"                    ;

            StringBuilder builder = new StringBuilder();

            foreach (Media media in medias)
            {
                string fullsizePath = UrlService.CreateImageUrl(Owner.Username, media.GetImageByPhotoType(PhotoType.Websize).FilePath);
                string thumbnail    = UrlService.CreateImageUrl(Owner.Username, media.GetImageByPhotoType(PhotoType.Thumbnail).FilePath);
                string showLink     = UrlService.UserUrl("photos/show/" + key + "/#/photo/" + media.MediaId);
                builder.AppendLine(string.Format(format, media.MediaId, fullsizePath, media.Title, thumbnail, showLink));
            }

            return(builder.ToString());
        }
        /// <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)));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the detail.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public JsonResult GetDetails(Guid id)
        {
            List <LoadedMedia> media = _mediaQueueRepository.GetLoadedMedia(id);

            return(Json(media.ConvertAll(o => new LoadedPhotos {
                Id = o.MediaId,
                Path = UrlService.CreateImageUrl(o.GetImageByPhotoType(PhotoType.Thumbnail).FilePath),
                Rel = UrlService.CreateImageUrl(o.GetImageByPhotoType(PhotoType.Websize).FilePath)
            })));
        }
        /// <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>
        /// 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);
        }
Exemplo n.º 7
0
        /// <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);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Renders the cover media.
        /// </summary>
        /// <returns></returns>
        public string RenderCoverMedia()
        {
            string html = string.Empty;

            if (CoverMedia != null)
            {
                MediaFile websize = CoverMedia.GetImageByPhotoType(PhotoType.Websize);
                html = string.Format("<label class=\"instructions\" style=\"margin-bottom:20px;\" >cover image</label><img  class=\"covermedia topten\"  src=\"{0}\" alt=\"{1}\" />", UrlService.CreateImageUrl(websize.FilePath), CoverMedia.Title);
            }

            return(html);
        }