Beispiel #1
0
        public static string Image(this HtmlHelper helper, Image image, int width, int height, bool fill, string defaultImage, DynamicImageFormat format)
        {
            string url = ImageUrl(helper, image, width, height, fill, defaultImage, format);
            if (string.IsNullOrEmpty(url))
                return string.Empty;

            return ImageTag(helper, image, url);
        }
Beispiel #2
0
        /// <summary>
        /// Image Tag methods
        /// </summary>
        public static string ImageTag(this HtmlHelper helper, Image image, string imageUrl)
        {
            TagBuilder imageTag = new TagBuilder("img");

            imageTag.MergeAttribute("src", imageUrl, true);
            imageTag.MergeAttribute("alt", image != null ? image.Caption : string.Empty, true);
            imageTag.MergeAttribute("border", "0", true);

            return imageTag.ToString(TagRenderMode.SelfClosing);
        }
Beispiel #3
0
        public static string ImageUrl(this HtmlHelper helper, Image image, int width, int height, bool fill, string defaultImage, DynamicImageFormat format)
        {
            string result = defaultImage;

            // only generate url if image exists
            if (image != null)
            {
                // special code for image without resizing
                if (width == 0 && height == 0)
                {
                    result = new CompositionBuilder()
                        .WithLayer(LayerBuilder.Image.SourceImage(image))
                        .Url;
                }

                // generate resized image url
                else
                {
                    if (image is CroppedImage)
                    {
                        CroppedImage cImage = (CroppedImage)image;
                        result = cImage.GetUrl(width, height, fill, format);
                    }
                    else
                    {
                        result = image.GetUrl(width, height, fill, format);
                    }
                }
            }

            return result;
        }
Beispiel #4
0
 public static string ImageUrl(this HtmlHelper helper, Image image, int width, int height, bool fill, DynamicImageFormat format)
 {
     return ImageUrl(helper, image, width, height, fill, string.Empty, format);
 }
Beispiel #5
0
 public static string ImageUrl(this HtmlHelper helper, Image image, int width, int height)
 {
     return ImageUrl(helper, image, width, height, true);
 }
Beispiel #6
0
 /// <summary>
 /// Image URL methods
 /// </summary>
 public static string ImageUrl(this HtmlHelper helper, Image image)
 {
     return ImageUrl(helper, image, 0, 0);
 }
Beispiel #7
0
 public static string Image(this HtmlHelper helper, Image image, int width, int height, bool fill, string defaultImage)
 {
     return Image(helper, image, width, height, fill, defaultImage, DynamicImageFormat.Jpeg);
 }
Beispiel #8
0
 public static string Image(this HtmlHelper helper, Image image, int width, int height, bool fill)
 {
     return Image(helper, image, width, height, fill, string.Empty);
 }
 public static ImageLayerBuilder SourceImage(this ImageLayerBuilder builder, Image image)
 {
     builder.Source = new ZeusImageSource { ContentID = image.ID };
     return builder;
 }