I am using a FileContentResult method to fetch a byte array from the database and render an image in the view. Works great but I can't figure out how to add an image alt tag (it would be the record name associated with the database record). I can either pass the name into the FileContentResult method or retrieve it from the database with the byte array and file type.
This is my return statement from the FileContentResult method:
return File(imageBinary, fileType);
This is my image tag from the view:
@foreach (var i in Model.Items)
{
<li>
<img src="@Url.Action("GetCatalogImage", "Gallery", new {ID=i.ItemID, Entity="item", Size="t" })" />
</li>
}
I'm not sure if what you are asking is possible. It would seem that, given you know the item ID when you populate the model in the first place, you could also at that point look up the alt tag (presumably stored in the database) and then pass that via the view model.
<img alt="@i.Alt" src="@Url.Actio....
I apologise if you have already thought of this solution and thought it not suitable!