Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 5
0
 public static string ImageUrl(this HtmlHelper helper, Image image, int width, int height)
 {
     return ImageUrl(helper, image, width, height, true);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Image URL methods
 /// </summary>
 public static string ImageUrl(this HtmlHelper helper, Image image)
 {
     return ImageUrl(helper, image, 0, 0);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 9
0
 public static ImageLayerBuilder SourceImage(this ImageLayerBuilder builder, Image image)
 {
     builder.Source = new ZeusImageSource { ContentID = image.ID };
     return builder;
 }