21 lines
661 B
C#
21 lines
661 B
C#
using System.Web.Mvc;
|
|
|
|
namespace Kreta.Web.Helpers
|
|
{
|
|
public static class ImageExtensions
|
|
{
|
|
public static MvcHtmlString Base64EncodedImage(this HtmlHelper htmlHelper, string encodedImage, string alText = default(string))
|
|
{
|
|
var tagBuilder = new TagBuilder("img");
|
|
|
|
tagBuilder.Attributes.Add("class", $"rounded mx-auto d-block");
|
|
tagBuilder.Attributes.Add("src", $"{encodedImage}");
|
|
|
|
if (!string.IsNullOrWhiteSpace(alText))
|
|
{
|
|
tagBuilder.Attributes.Add("alt", alText);
|
|
}
|
|
return new MvcHtmlString(tagBuilder.ToString());
|
|
}
|
|
}
|
|
}
|