///// <summary> ///// ///// </summary> ///// <param name="originalPath"></param> ///// <param name="fileName"></param> ///// <param name="thumbnail"></param> ///// <param name="scaleMode"></param> //public static void SaveCachedImage(string originalPath, string fileName, ThumbnailPicture thumbnail, ScaleMode scaleMode) //{ // CacheImage(originalPath, fileName, thumbnail.CacheFolder, thumbnail.PictureSize, scaleMode, false, 0); //} public static void SaveCachedImage(string originalPath, string fileName, ThumbnailPicture thumbnail) { string cachePath = HttpContext.Current.Server.MapPath("~/ImageCache/" + thumbnail.CacheFolder); string cachedImagePath = Path.Combine(cachePath, fileName); if (!File.Exists(cachedImagePath)) { CacheImage(originalPath, fileName, thumbnail.CacheFolder, thumbnail.PictureSize, thumbnail.ScaleMode, false, 0); } }
public static string CachedImage2(this HtmlHelper helper, string originalPath, string fileName, string fileName2, ThumbnailPicture thumbnail) { StringBuilder sb = new StringBuilder(); string formatString = "<img src=\"{0}\" alt=\"{1}\" width=\"{2}\" height=\"{3}\" />"; sb.AppendFormat(formatString, GetCachedImage(originalPath, fileName, thumbnail), fileName2, _width, _height); return sb.ToString(); }
public static string CachedImage(this HtmlHelper helper, string originalPath, string fileName, ThumbnailPicture thumbnail) { return CachedImage(helper, originalPath, fileName, thumbnail, null); }
public static string CachedImage(this HtmlHelper helper, string originalPath, string fileName, ThumbnailPicture thumbnail, string className) { StringBuilder sb = new StringBuilder(); string formatString = "<img src=\"{0}\" alt=\"{1}\" class=\"{2}\" width=\"{3}\" height=\"{4}\" />"; //string formatString = "<img src=\"{0}\" alt=\"{1}\" class=\"{2}\" />"; string imageSrc = GetCachedImage(originalPath, fileName, thumbnail); if (string.IsNullOrEmpty(imageSrc)) //return string.Format("image file {0} not found", fileName); return string.Format("file not found", fileName); sb.AppendFormat(formatString, VirtualPathUtility.ToAbsolute(imageSrc ?? ""), fileName, className ?? "", _width, _height); return sb.ToString(); }
public static string GetCachedImage(string originalPath, string fileName, ThumbnailPicture thumbnail) { if (string.IsNullOrEmpty(fileName) || !File.Exists(Path.Combine(HttpContext.Current.Server.MapPath(originalPath), fileName))) { return null; } string cacheFolder = thumbnail.CacheFolder; string result = Path.Combine("~/ImageCache/" + cacheFolder + "/", fileName); string cachePath = HttpContext.Current.Server.MapPath("~/ImageCache/" + cacheFolder); if (!Directory.Exists(cachePath)) Directory.CreateDirectory(cachePath); string cachedImagePath = Path.Combine(cachePath, fileName); if (File.Exists(cachedImagePath)) { GetImageSize(result); return result; } if (CacheImage(originalPath, fileName, cacheFolder, thumbnail.PictureSize, thumbnail.ScaleMode, thumbnail.UseBackgroundImage, thumbnail.Offset)) { GetImageSize(result); return result; } return null; }