public UploadController() { MediaRootDir = ConfigurationManager.AppSettings["MediaBasePath"]; repo = new MediaRepository(); }
private void _LoadImage() { MediaRepository mediaRepo = new MediaRepository(); //Umbraco.Web.Media.ImageUrlProviders.ImageUrlProvider p = new Umbraco.Web.Media.ImageUrlProviders.ImageUrlProvider(); // Dictionary<string, string> parameters = new Dictionary<string, string>(); string url = ""; if (IsUmbracoImage) { url = ""; url = CurrentContext.Server.MapPath(mediaRepo.GetByObsoleteID(int.Parse(IMGID)).FileName); } else { url = CurrentContext.Server.MapPath(IMGID); } if (File.Exists(url)) { FileInfo info = new FileInfo(url); using (Image img = Image.FromFile(url)) { OriginWidth = img.Width; OriginHeight = img.Height; if (Thumb) { _WriteThumbnail(img, info); } else { if (!FetchOrigin) { if (DoCrop) { _Crop(); if (IsCroppable) { _WriteCroppedImage(img, info); } else { _CalcRatio(); _WriteScaledImage(img, info); } } else { _CalcRatio(); _WriteScaledImage(img, info); } } else { _WriteOriginImage(img, info); } } } } else { CurrentContext.Response.StatusCode = 404; CurrentContext.Response.Write("FILE NOT FOUND: " + url); } }