/// <summary>
/// Write out a media item with a responsive url
/// </summary>
/// <param name="helper"></param>
/// <param name="media">The media item to write out</param>
/// <param name="widthFactor">The factor to apply to the width - can be % (eg "100%") or absolute (eg "120")</param>
/// <param name="aspect">The aspect ratio for the image</param>
/// <param name="cssClass">Css class to apply to img tag</param>
/// <param name="containerSize">The size (in grid column units) of the containing element</param>
/// <returns>Complete media markup with all required attributes</returns>
public static MvcHtmlString Media(this HtmlHelper helper, MediaItem media, string widthFactor, double aspect, string cssClass = null, int containerSize = 0)
{
using (new Tracer(helper, media, widthFactor, aspect, cssClass, containerSize))
{
if (media == null)
{
return MvcHtmlString.Empty;
}
//We read the container size (based on bootstrap grid) from the view bag
//This means views can be independent of where they are rendered and do not
//need to know their width
if (containerSize == 0)
{
containerSize = helper.ViewBag.ContainerSize;
}
return new MvcHtmlString(media.ToHtml(widthFactor, aspect, cssClass, containerSize));
}
}