Inheritance: EntityModel
Ejemplo n.º 1
0
 /// <summary>
 /// Return background image style attribute
 /// </summary>
 /// <param name="htmlHelper">HtmlHelper</param>
 /// <param name="image">The image</param>
 /// <returns>The background image style attribute, or empty string if no image available</returns>
 public static MvcHtmlString BgImgStyle(this HtmlHelper htmlHelper, MediaItem image)
 {
     if (image == null || String.IsNullOrEmpty(image.Url))
     {
         return null;
     }
     return new MvcHtmlString(String.Format("style=\"background-image:url('{0}');\"", image.Url));
 }
Ejemplo n.º 2
0
 public static MvcHtmlString Media(this HtmlHelper helper, MediaItem media, double aspect, string cssClass = null)
 {
     return Media(helper, media, null, aspect, cssClass);
 }
Ejemplo n.º 3
0
 public static MvcHtmlString Media(this HtmlHelper helper, MediaItem media, string widthFactor, string cssClass = null)
 {
     return Media(helper, media, widthFactor, SiteConfiguration.MediaHelper.DefaultMediaAspect, cssClass);
 }
Ejemplo n.º 4
0
 public static MvcHtmlString Media(this HtmlHelper helper, MediaItem media)
 {
     return Media(helper, media, null);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Write out an 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)
 {
     if (media == null)
     {
         return null;
     }
     //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;
     }
     if (media is Image)
     {
         return Image(helper, (Image)media, widthFactor, aspect, cssClass, containerSize);
     }
     if (media is YouTubeVideo)
     {
         return YouTubeVideo(helper, (YouTubeVideo)media, widthFactor, aspect, cssClass, containerSize);
     }
     if (media is Download)
     {
         return Download(helper, (Download)media);
     }
     return null;
 }
        /// <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));
            }
        }
 public static MvcHtmlString Download(this HtmlHelper helper, MediaItem download)
 {
     using (new Tracer(helper, download))
     {
         if (download == null)
         {
             return MvcHtmlString.Empty;
         }
         return new MvcHtmlString(download.ToHtml(null));
     }
 }
 public static MvcHtmlString YouTubeVideo(this HtmlHelper helper, MediaItem video, string widthFactor, double aspect, string cssClass, int containerSize)
 {
     return Media(helper, video, widthFactor, aspect, cssClass, containerSize);
 }
 public static MvcHtmlString Image(this HtmlHelper helper, MediaItem image, string widthFactor, double aspect, string cssClass = null, int containerSize = 0)
 {
     return Media(helper, image, widthFactor, aspect, cssClass, containerSize);
 }