/// <summary> /// Write out an youtube video item /// </summary> /// <param name="helper"></param> /// <param name="media">The video 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 video</param> /// <param name="cssClass">Css class to apply</param> /// <param name="containerSize">The size (in grid column units) of the containing element</param> /// <returns>Complete video markup with all required attributes</returns> public static MvcHtmlString YouTubeVideo(HtmlHelper helper, YouTubeVideo video, string widthFactor, double aspect, string cssClass, int containerSize) { if (video == null || String.IsNullOrEmpty(video.YouTubeId)) { return null; } if (video.Url != null && SiteConfiguration.MediaHelper.ShowVideoPlaceholders) { //we have a placeholder image var placeholderImgUrl = SiteConfiguration.MediaHelper.GetResponsiveImageUrl(video.Url, aspect, widthFactor, containerSize); return new MvcHtmlString(GetYouTubePlaceholder(video.YouTubeId, placeholderImgUrl, video.Headline, cssClass)); } return new MvcHtmlString(GetYouTubeEmbed(video.YouTubeId, cssClass)); }
public static MvcHtmlString YouTubeVideo(this HtmlHelper helper, YouTubeVideo video, string widthFactor, double aspect, string cssClass, int containerSize) { using (new Tracer(helper, video, widthFactor, aspect, cssClass, containerSize)) { if (video == null || string.IsNullOrEmpty(video.YouTubeId)) { return MvcHtmlString.Empty; } return new MvcHtmlString(video.ToHtml(widthFactor, aspect, cssClass, containerSize)); } }