/// <summary> /// Create SourceImageViewModel for Detail View /// </summary> /// <param name="sourceImage">sourceImage</param> /// <returns>SourceImageViewModel with all data ready to be displayed</returns> public static SourceImageViewModel GetSourceImageViewModel(SourceImage sourceImage, List <ThumbImage> thumbs) { if (sourceImage == null) { return(null); } // Build sizes component StringBuilder sizes = new StringBuilder(); foreach (ThumbImage thumb in thumbs) { sizes.Append(thumb.RelativePath); sizes.Append(" "); sizes.Append(thumb.Width); sizes.Append("w, "); } return(new SourceImageViewModel { ID = sourceImage.ID, FileName = sourceImage.FileName, AltText = sourceImage.AltText, FallbackPath = sourceImage.RelativePath, Width = sourceImage.Width.ToString(), Height = sourceImage.Height.ToString(), FileFormat = sourceImage.Format.ToString(), Thumbnails = thumbs, Metadata = sourceImage.Metadata, Sizes = sourceImage.Format == Format.SVG ? "" : sizes.ToString(), FileSize = sourceImage.FileSize.ToString(), HumanSize = sourceImage.getFileSize() }); }