/// <summary> /// returns path to thumbnail, if thumbnail does not exist it creates it then returns the new path /// </summary> /// <param name="filePath">the path to the thumbnail, usually stored in db</param> /// <param name="imgsize"></param> /// <param name="returnLocalFileOnly"></param> /// <returns></returns> public static string by_size(string filePath, Imgsize type) { var dim = getImageDimensionsFromSize(type); int width = dim.Width; int height = dim.Height; // appends dimension to path string suffix = type.ToString().ToLower(); string ofile; string thumb = ofile = filePath; string ext = thumb.Substring(thumb.LastIndexOf(".") + 1); string part1 = thumb.Substring(0, thumb.LastIndexOf(".")); if (part1.IndexOf(".") == -1) { thumb = part1 + "_" + suffix + "." + ext; } else { string part2 = part1.Substring(0, part1.LastIndexOf(".")); thumb = part2 + "_" + suffix + "." + ext; } bool fileExist = false; #if AZURE fileExist = photoContainer.DoesBlobItemExists(thumb); #else #if RACKSPACE // check if thumbnail exists on rackspace first if (!returnLocalFileOnly) { CloudFile cf = new CloudFile(Constants.RACKSPACE_CONTAINER_IMAGES); fileExist = cf.DoesBlobItemExists(Path.GetFileName(thumb)); if (fileExist) { thumb = cf.GetBlobItemUri(Path.GetFileName(thumb)); } } #endif if (!fileExist) { fileExist = File.Exists(GeneralConstants.APP_ROOT_DIR + thumb); } #endif if (!fileExist) { thumb = thumbnail(ofile, suffix, width, height, type); } #if AZURE if (!string.IsNullOrEmpty(thumb)) { return(photoContainer.GetBlobItemUri(thumb)); } else { return(""); } #else return(thumb); #endif }