public static bool IsProfileImage(this ImageIndexs imageIndex) { switch (imageIndex) { case ImageIndexs.Profile_220X300: case ImageIndexs.ProfileLogin_120X120: return(true); default: return(false); } }
public static bool IsProductImage(this ImageIndexs imageIndex) { switch (imageIndex) { case ImageIndexs.Product1_360X420: case ImageIndexs.Product2_360X420: return(true); default: return(false); } }
public static bool IsBannerImage(this ImageIndexs imageIndex) { switch (imageIndex) { case ImageIndexs.Banner1_1920X1080: case ImageIndexs.Banner2_1920X1080: case ImageIndexs.Banner3_1920X1080: case ImageIndexs.Banner4_1920X1080: return(true); default: return(false); } }
public static bool IsMediaImage(this ImageIndexs imageIndex) { if (imageIndex == ImageIndexs.MediaImage_autoXauto) { return(true); } else if (imageIndex.ToString().IndexOf("MediaImage_") >= 0) { return(true); } else { return(false); } }
public static bool IsProductDescImage(this ImageIndexs imageIndex) { switch (imageIndex) { case ImageIndexs.ProductDesc1_512X310: case ImageIndexs.ProductDesc2_512X310: case ImageIndexs.ProductDesc3_512X310: case ImageIndexs.ProductDesc4_512X310: case ImageIndexs.ProductDesc5_1920X1080: case ImageIndexs.ProductDesc6_1920X1080: case ImageIndexs.ProductDesc7_1920X1080: case ImageIndexs.ProductDesc8_1920X1080: return(true); default: return(false); } }
public static bool IsItemImage(this ImageIndexs imageIndex) { switch (imageIndex) { case ImageIndexs.Item1_1024X620: case ImageIndexs.Item2_1024X620: case ImageIndexs.Item3_1024X620: case ImageIndexs.Item4_1024X620: case ImageIndexs.Item5_1024X620: case ImageIndexs.Item6_1024X620: case ImageIndexs.Item7_1024X620: case ImageIndexs.Item8_1024X620: case ImageIndexs.Item0_102X120: return(true); default: return(false); } }
public ImageProfile(string personId, ImageIndexs index, string url) { this.PersonId = personId; this.ProfileImgIndex = index; this.ImageUrl = url; }
public async Task <IViewComponentResult> InvokeAsync(string path, ImageIndexs fileIndex, string mimeType = Image.Jpeg, string imageOnly = "false", string animated = "false", string background = "false") { var viewName = "Default"; var fileName = fileIndex.ToString().Split('_')[0].ToLower(); var staticImg = new StaticImageDto() { Path = path, FileIndex = fileIndex, FileName = fileName, MimeType = mimeType, ImageOnly = bool.Parse(imageOnly), Animated = bool.Parse(animated), Background = bool.Parse(background), }; var extension = mimeType.Split('/')[1]; var filePath = Path.Combine(Directory.GetCurrentDirectory(), Path.Combine(path, fileName)) + "."; var fileExist = File.Exists(filePath + extension); if (fileExist) { filePath = filePath + extension; } else { extension = "jpg"; fileExist = File.Exists(filePath + extension); if (fileExist) { filePath = filePath + extension; } else { mimeType = Image.Gif; extension = mimeType.Split('/')[1]; fileExist = File.Exists(filePath + extension); if (fileExist) { filePath = filePath + extension; } else { mimeType = Image.Tiff; extension = mimeType.Split('/')[1]; fileExist = File.Exists(filePath + extension); if (fileExist) { filePath = filePath + extension; } else { extension = "png"; fileExist = File.Exists(filePath + extension); if (fileExist) { filePath = filePath + extension; } else { extension = "svg"; fileExist = File.Exists(filePath + extension); if (fileExist) { filePath = filePath + extension; } } } } } } if (fileExist) { viewName = "StaticImage"; FileInfo fileInfo = new FileInfo(filePath); staticImg.FileInfo = fileInfo; staticImg.Url = filePath.Substring(filePath.IndexOf("wwwroot") + 7); // faster, as of different C# researchers // staticImg.Url = fileInfo.DirectoryName.Substring(fileInfo.DirectoryName.IndexOf("wwwroot") + 7) + fileInfo.Name; staticImg.MimeType = mimeType; staticImg.Path = filePath; staticImg.UploadDate = File.GetLastWriteTime(filePath); } return(View(viewName, staticImg)); }