In our ASP.NET MVC 3 We are currently generating thumbnail images on the fly with the following code:
public void GetImageThumbnail(string imageName)
{
WebImage wbImage = new WebImage("~/assets/images/gallery/"+imageName+".jpg");
int width = 220;
wbImage.Resize(width, (int)((double)wbImage.Height * width / wbImage.Width));
wbImage.FileName = imageName+"_small.jpg";
wbImage.Write();
}
and displaying them in the view like this:
<img src="@Url.Action("GetImageThumbnail", new {imageName = "motherboard"})" alt="" />
How can we control the image size on the view and generate the complete <img>
tag from scratch? We need to specify the image dimension and obtain an <img>
tag the contains the width
and height
properties.
Thanks.