Example #1
0
        protected override void ProcessMedia(TagHelperContext context, TagHelperOutput output)
        {
            if (Src.IsEmpty())
            {
                output.SuppressOutput();
                return;
            }

            output.AppendCssClass("file-img");
            output.Attributes.SetAttribute("src", Src);

            output.Attributes.SetAttributeNoReplace("alt", () => Model?.Alt ?? File?.File?.GetLocalized(x => x.Alt)?.Value.NullEmpty());
            output.Attributes.SetAttributeNoReplace("title", () => Model?.Title ?? File?.File?.GetLocalized(x => x.Title)?.Value.NullEmpty());
        }
Example #2
0
        protected override void ProcessMedia(TagHelperContext context, TagHelperOutput output)
        {
            if (Src.IsEmpty())
            {
                output.SuppressOutput();
                return;
            }

            var mediaType = File?.MediaType ?? MediaType.Image;

            // Root
            output.TagName = "figure";
            output.TagMode = TagMode.StartTagAndEndTag;
            output.AppendCssClass("file-figure");

            // Build <i/>
            var iconHint = GetIconHint(mediaType);
            var ic       = new TagBuilder("i");

            ic.Attributes["class"] = "file-icon show fa-5x fa-fw " + iconHint.Name;
            ic.Attributes["style"] = "color: " + iconHint.Color;

            // Append <i/> to root <figure/>
            output.Content.AppendHtml(ic);

            // Build <picture/>
            var picture = new TagBuilder("picture");

            picture.Attributes["class"]     = "file-thumb";
            picture.Attributes["data-type"] = mediaType;
            output.Attributes.MoveAttribute(picture, "title");
            picture.MergeAttribute("title", () => File?.File?.GetLocalized(x => x.Title).Value.NullEmpty(), false, true);

            // Build <img/>
            var img = new TagBuilder("img")
            {
                TagRenderMode = TagRenderMode.SelfClosing
            };

            img.Attributes["class"]    = "file-img";
            img.Attributes["data-src"] = Src;
            img.MergeAttribute("alt", () => File?.File?.GetLocalized(x => x.Alt).Value.NullEmpty(), false, true);

            // picture > img
            picture.InnerHtml.SetHtmlContent(img);

            // Append <picture/> to root <figure/>
            output.Content.AppendHtml(picture);
        }
Example #3
0
        protected override void ProcessMedia(TagHelperContext context, TagHelperOutput output)
        {
            if (Src.IsEmpty() || File == null)
            {
                output.SuppressOutput();
                return;
            }

            output.Attributes.SetAttribute("src", Src);
            output.AppendCssClass("file-preview");
            output.Attributes.SetAttributeNoReplace("title", () => File.File.GetLocalized(x => x.Title)?.Value.NullEmpty());
            output.Attributes.SetAttributeNoReplace("preload", "metadata");

            if (!output.Attributes.ContainsName("controls"))
            {
                output.Attributes.Add(new TagHelperAttribute("controls", null, HtmlAttributeValueStyle.Minimized));
            }
        }
        protected override void ProcessMedia(TagHelperContext context, TagHelperOutput output)
        {
            if (Src.IsEmpty() || File == null)
            {
                output.SuppressOutput();
                return;
            }

            var tagHelper = CreateInnerTagHelper(context, output);

            if (tagHelper != null)
            {
                tagHelper.Process(context, output);
            }
            else
            {
                output.SuppressOutput();
            }
        }