seed avec nouvelles images (les images de seed commencent par $)
This commit is contained in:
@@ -128,7 +128,7 @@ public class ProductController : ControllerBase {
|
||||
|
||||
#region Internal Methods
|
||||
private async Task<string> SaveImage(IFormFile imageFile) {
|
||||
string imageName = new String(Path.GetFileNameWithoutExtension(imageFile.FileName).Take(10).ToArray()).Replace(' ', '-');
|
||||
string imageName = new String(Path.GetFileNameWithoutExtension(imageFile.FileName).Take(10).ToArray()).Replace(' ', '-').Replace("$","");
|
||||
imageName = imageName + DateTime.Now.ToString("yymmssfff") + Path.GetExtension(imageFile.FileName);
|
||||
var imagePath = Path.Combine(_hostEnvironment.ContentRootPath, "Images", imageName);
|
||||
|
||||
@@ -141,10 +141,10 @@ public class ProductController : ControllerBase {
|
||||
|
||||
private void SaveImageThumbnail(FileStream stream, string imageName) {
|
||||
try {
|
||||
const float maxSize = 200f;
|
||||
const float maxSize = 300f;
|
||||
Image image = Image.FromStream(stream);
|
||||
|
||||
//Choisi le bon ratio de division pour ne pas dépasser le 200px ni dans height ni dans width
|
||||
//Choisi le bon ratio de division pour ne pas dépasser le 300px ni dans height ni dans width
|
||||
float ratio = image.Width / (image.Height / maxSize) <= maxSize ? image.Height / maxSize : image.Width / maxSize;
|
||||
|
||||
Bitmap resize = new Bitmap(image, new Size((int)(image.Width / ratio), (int)(image.Height / ratio)));
|
||||
@@ -158,7 +158,7 @@ public class ProductController : ControllerBase {
|
||||
|
||||
private void DeleteImages(string imageName) {
|
||||
|
||||
if (imageName == "default.jpg" || imageName == "default_thumbnail.jpg")
|
||||
if (imageName == "default.jpg" || imageName == "default_thumbnail.jpg" || imageName.Contains("$"))
|
||||
return;
|
||||
|
||||
var files = System.IO.Directory.GetFiles(_hostEnvironment.ContentRootPath + "/Images")
|
||||
|
Reference in New Issue
Block a user