public ImageResult GetImage(int id, string hash, ImageHelper.ImageSize dimensions) { var image = imageService.Find(id); var imageSize = ImageHelper.GetDefaultImageDimensions(dimensions); if (image == null || image.Hash != hash) { return GetDefaultImage(dimensions); } var imageFile = ImageHelper.GetImageFilePath(image.Hash, image.CreateDate); if (!System.IO.File.Exists(imageFile)) { return GetDefaultImage(dimensions); } Response.AppendHeader("content-disposition", "attachment; filename=" + image.Name); var webImage = new WebImage(imageFile); ImageHelper.ResizeImage(ref webImage, imageSize.Width, imageSize.Height); return new ImageResult {Image = webImage, ImageFormat = ImageHelper.GetImageFormat(image.Name)}; }
public ImageResult GetDefaultImage(ImageHelper.ImageSize dimensions) { var imageSize = ImageHelper.GetDefaultImageDimensions(dimensions); return ImageHelper.GetDefaultImage(imageSize); }