ImageTagHelper #2516

Merged
merged 1 commit into from May 11, 2015

Projects

None yet

5 participants

@dpaquette
Contributor

An ImageTagHelper that supports globbed src paths and cache busting file
version hash
[Resolves #2249]

@dnfclas
dnfclas commented May 7, 2015

Hi @dpaquette, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. I promise there's no faxing. https://cla2.dotnetfoundation.org.

TTYL, DNFBOT;

@dnfclas dnfclas added the cla-required label May 7, 2015
@dpaquette
Contributor

What's the deal with @dnfclas ? I signed my cla before submitting this PR

@dougbu
Member
dougbu commented May 8, 2015

@dpaquette We just changed the repos from MS Open Tech to .NET Foundation so there's a different CLA. The new CLA is simpler than the old one and so should only take a few moments to re-sign. Apologies for the extra bit of work!

@dnfclas
dnfclas commented May 8, 2015

@dpaquette, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.

Thanks, DNFBOT;

@dnfclas dnfclas added cla-signed and removed cla-required labels May 8, 2015
@Eilon Eilon and 2 others commented on an outdated diff May 8, 2015
src/Microsoft.AspNet.Mvc.TagHelpers/ImageTagHelper.cs
+ /// Src of the image.
+ /// </summary>
+ /// <remarks>
+ /// Passed through to the generated HTML in all cases.
+ /// </remarks>
+ [HtmlAttributeName(SrcAttributeName)]
+ public string Src { get; set; }
+
+ /// <summary>
+ /// Value indicating if file version should be appended to the src urls.
+ /// </summary>
+ /// <remarks>
+ /// If <c>true</c> then a query string "v" with the encoded content of the file is added.
+ /// </remarks>
+ [HtmlAttributeName(FileVersionAttributeName)]
+ public bool? FileVersion { get; set; }
@Eilon
Eilon May 8, 2015 Member

IncludeFileVersion? Or maybe AppendFileVersion? The current name makes it sound like it is a file version (e.g. you'd set asp-file-version="1.23.4" or something).

@dpaquette
dpaquette May 8, 2015 Contributor

I agree that AppendFileVersion or AddFileVersion would make more sense. This is modeled off the Link and Script tag helpers. If we change the name here then it would need to be changed on both those tag helpers too.

@NTaylorMullen
NTaylorMullen May 10, 2015 Member

Why nullable? It's in the TargetElement so it'll always be provided.

@Eilon Eilon and 1 other commented on an outdated diff May 8, 2015
src/Microsoft.AspNet.Mvc.TagHelpers/ImageTagHelper.cs
+ [TargetElement("img", Attributes = FileVersionAttributeName)]
+ public class ImageTagHelper : TagHelper
+ {
+ private static readonly string Namespace = typeof(ImageTagHelper).Namespace;
+
+ private const string FileVersionAttributeName = "asp-file-version";
+ private const string SrcAttributeName = "src";
+
+ private FileVersionProvider _fileVersionProvider;
+
+ private static readonly ModeAttributes<Mode>[] ModeDetails = new[] {
+ // Regular src with file version
+ ModeAttributes.Create(Mode.FileVersion, new[] { FileVersionAttributeName }),
+ };
+
+ private enum Mode
@Eilon
Eilon May 8, 2015 Member

A single-value enum is... weird. Is it supposed to be more like None=0, FileVersion=1 or something? Not sure I quite get how this works.

@dpaquette
dpaquette May 8, 2015 Contributor

This could be a boolean now. It previously had multiple modes back when this supported src globbing.

@dpaquette
Contributor

@Eilon I simplified the ImageTagHelper class by removing the Mode and Mode Detection code since this was no longer needed. Not sure what we should do about the naming of the asp-file-version attribute.

@dougbu dougbu commented on an outdated diff May 10, 2015
src/Microsoft.AspNet.Mvc.TagHelpers/ImageTagHelper.cs
+ /// </summary>
+ /// <remarks>
+ /// The tag helper won't process for cases with just the 'src' attribute.
+ /// </remarks>
+ [TargetElement("img", Attributes = FileVersionAttributeName)]
+ public class ImageTagHelper : TagHelper
+ {
+ private static readonly string Namespace = typeof(ImageTagHelper).Namespace;
+
+ private const string FileVersionAttributeName = "asp-file-version";
+ private const string SrcAttributeName = "src";
+
+ private FileVersionProvider _fileVersionProvider;
+
+ /// <summary>
+ /// Src of the image.
@dougbu
dougbu May 10, 2015 Member

Source

@dougbu dougbu commented on an outdated diff May 10, 2015
src/Microsoft.AspNet.Mvc.TagHelpers/ImageTagHelper.cs
+ {
+ output.CopyHtmlAttribute(SrcAttributeName, context);
+ }
+
+ // NOTE: Values in TagHelperOutput.Attributes may already be HTML-encoded.
+ var attributes = new TagHelperAttributeList(output.Attributes);
+ var builder = new DefaultTagHelperContent();
+
+ if (context.AllAttributes.ContainsName(FileVersionAttributeName))
+ {
+ // Build a <img /> tag to match the original one in the source file.
+ // Or just add file version to the img tag.
+ BuildImageTag(attributes, builder);
+ } else
+ {
+ //No attributes matched so we have nothing to do
@dougbu
dougbu May 10, 2015 Member

else on its own line and always include a space after //

@dougbu dougbu commented on an outdated diff May 10, 2015
src/Microsoft.AspNet.Mvc.TagHelpers/ImageTagHelper.cs
+
+ private void BuildImageTag(TagHelperAttributeList attributes, TagHelperContent builder)
+ {
+ EnsureFileVersionProvider();
+ builder.Append("<img ");
+
+ foreach (var attribute in attributes)
+ {
+ var attributeValue = attribute.Value;
+ if (FileVersion == true &&
+ string.Equals(attribute.Name, SrcAttributeName, StringComparison.OrdinalIgnoreCase))
+ {
+ // "src" values come from bound attributes and globbing. So anything but a non-null string is
+ // unexpected but could happen if another helper targeting the same element does something odd.
+ // Pass through existing value in that case.
+ var attributeStringValue = attributeValue as string;
@dougbu
dougbu May 10, 2015 Member

This isn't necessary since Src is bound.

@dougbu dougbu commented on an outdated diff May 10, 2015
src/Microsoft.AspNet.Mvc.TagHelpers/ImageTagHelper.cs
+ string.Equals(attribute.Name, SrcAttributeName, StringComparison.OrdinalIgnoreCase))
+ {
+ // "src" values come from bound attributes and globbing. So anything but a non-null string is
+ // unexpected but could happen if another helper targeting the same element does something odd.
+ // Pass through existing value in that case.
+ var attributeStringValue = attributeValue as string;
+ if (attributeStringValue != null)
+ {
+ attributeValue = _fileVersionProvider.AddFileVersionToPath(attributeStringValue);
+ }
+ }
+
+ builder
+ .Append(attribute.Name)
+ .Append("=\"")
+ .Append(HtmlEncoder, ViewContext.Writer.Encoding, attributeValue)
@dougbu
dougbu May 10, 2015 Member

For every attribute except Src, this usually double-encode the attribute value.

@dougbu dougbu commented on an outdated diff May 10, 2015
src/Microsoft.AspNet.Mvc.TagHelpers/ImageTagHelper.cs
+ /// </remarks>
+ [HtmlAttributeName(SrcAttributeName)]
+ public string Src { get; set; }
+
+ /// <summary>
+ /// Value indicating if file version should be appended to the src urls.
+ /// </summary>
+ /// <remarks>
+ /// If <c>true</c> then a query string "v" with the encoded content of the file is added.
+ /// </remarks>
+ [HtmlAttributeName(FileVersionAttributeName)]
+ public bool? FileVersion { get; set; }
+
+ [Activate]
+ [HtmlAttributeNotBound]
+ protected internal ILogger<ImageTagHelper> Logger { get; set; }
@dougbu
dougbu May 10, 2015 Member

unused

@dougbu dougbu commented on an outdated diff May 10, 2015
src/Microsoft.AspNet.Mvc.TagHelpers/ImageTagHelper.cs
+
+ [Activate]
+ [HtmlAttributeNotBound]
+ public ViewContext ViewContext { get; set; }
+
+ [Activate]
+ [HtmlAttributeNotBound]
+ public IMemoryCache Cache { get; set; }
+
+ [Activate]
+ [HtmlAttributeNotBound]
+ public IHtmlEncoder HtmlEncoder { get; set; }
+
+ [Activate]
+ [HtmlAttributeNotBound]
+ public IJavaScriptStringEncoder JavaScriptEncoder { get; set; }
@dougbu
dougbu May 10, 2015 Member

unused

@dougbu dougbu commented on an outdated diff May 10, 2015
src/Microsoft.AspNet.Mvc.TagHelpers/ImageTagHelper.cs
+ [Activate]
+ [HtmlAttributeNotBound]
+ public IMemoryCache Cache { get; set; }
+
+ [Activate]
+ [HtmlAttributeNotBound]
+ public IHtmlEncoder HtmlEncoder { get; set; }
+
+ [Activate]
+ [HtmlAttributeNotBound]
+ public IJavaScriptStringEncoder JavaScriptEncoder { get; set; }
+
+ /// <inheritdoc />
+ public override void Process(TagHelperContext context, TagHelperOutput output)
+ {
+ // Pass through attribute that is also a well-known HTML attribute.
@dougbu
dougbu May 10, 2015 Member

Entire method could be significantly simplified since <link> and <script> tag helpers only need SetContent() workaround due to globbing. For example:

public override void Process(TagHelperContext context, TagHelperOutput output)
{
    if (Src != null)
    {
        if (FileVersion == true)
        {
            EnsureFileVersionProvider();
            output.Attributes[SrcAttributeName] = _fileVersionProvider.AddFileVersionToPath(Src);
        }
        else
        {
            // Pass through attribute that is also a well-known HTML attribute.
            output.CopyHtmlAttribute(SrcAttributeName, context);
        }
    }
}
@dougbu dougbu commented on the diff May 10, 2015
...ersWebSite/Controllers/MvcTagHelper_HomeController.cs
@@ -162,6 +162,11 @@ public IActionResult Link()
return View();
}
+ public IActionResult Image()
@dougbu
dougbu May 10, 2015 Member

Need another test in MvcTagHelpersTest. This addition isn't confirmed otherwise.

@dougbu
Member
dougbu commented May 10, 2015

⌚️

@dpaquette
Contributor

@dougbu Simplified implementation and updated tests as per your comments

@dougbu dougbu commented on an outdated diff May 10, 2015
...soft.AspNet.Mvc.TagHelpers.Test/ImageTagHelperTest.cs
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.AspNet.FileProviders;
+using Microsoft.AspNet.Hosting;
+using Microsoft.AspNet.Http.Internal;
+using Microsoft.AspNet.Mvc.ModelBinding;
+using Microsoft.AspNet.Mvc.Rendering;
+using Microsoft.AspNet.Razor.Runtime.TagHelpers;
+using Microsoft.AspNet.Routing;
+using Microsoft.Framework.Caching;
+using Microsoft.Framework.Caching.Memory;
+using Microsoft.Framework.Runtime;
+
+using Moq;
+using Xunit;
@dougbu
dougbu May 10, 2015 Member

Please remove and sort usings. That should also clean up the extra blank line.

@NTaylorMullen NTaylorMullen commented on the diff May 10, 2015
src/Microsoft.AspNet.Mvc.TagHelpers/ImageTagHelper.cs
+ {
+ private static readonly string Namespace = typeof(ImageTagHelper).Namespace;
+
+ private const string FileVersionAttributeName = "asp-file-version";
+ private const string SrcAttributeName = "src";
+
+ private FileVersionProvider _fileVersionProvider;
+
+ /// <summary>
+ /// Source of the image.
+ /// </summary>
+ /// <remarks>
+ /// Passed through to the generated HTML in all cases.
+ /// </remarks>
+ [HtmlAttributeName(SrcAttributeName)]
+ public string Src { get; set; }
@NTaylorMullen
NTaylorMullen May 10, 2015 Member

Don't bind this and just add it to the [TargetElement], Aka [TargetElement("img", Attributes = FileVersionAttributeName + ",src")]. That way you don't have to restore it or check for null.

@dougbu
dougbu May 10, 2015 Member

@NTaylorMullen your advice is incorrect. This is the way to ensure the tag helper gets the non-HTML encoded value of the src attribute.

@NTaylorMullen
NTaylorMullen May 10, 2015 Member

Ah, fair point since we're modifying it. 👍

@NTaylorMullen
NTaylorMullen May 10, 2015 Member

Probably still worth adding it to TargetElement since it no-ops otherwise. Also, since it's a string a null value wont be possible (for the TagHelper) if its in the TargetElement.

@dougbu
dougbu May 10, 2015 Member

since it's a string a null value wont be possible if its in TargetElement.

Side note: Put that way, it sounds like a bug. Razor doesn't do what author likely meant if author writes src="@null" for a bound string attribute.

But I agree having both SrcAttributeName and FileVersionAttributeName in the TargetElement.Attributes value makes sense. Avoids some useless executions of the helper.

@NTaylorMullen NTaylorMullen commented on an outdated diff May 10, 2015
...osoft.AspNet.Mvc.FunctionalTests/MvcTagHelpersTest.cs
@@ -47,6 +47,8 @@ public class MvcTagHelpersTest
[InlineData("Link", null)]
// Testing the ScriptTagHelper
[InlineData("Script", null)]
+ //Testing the ImageTagHelper
@NTaylorMullen
NTaylorMullen May 10, 2015 Member

// Testing the ImageTagHelper

@dougbu dougbu commented on the diff May 10, 2015
...soft.AspNet.Mvc.TagHelpers.Test/ImageTagHelperTest.cs
+ attributes: new TagHelperAttributeList
+ {
+ { "alt", new HtmlString("alt text") },
+ { "data-extra", new HtmlString("something") },
+ { "title", new HtmlString("Image title") },
+ { "src", "testimage.png" },
+ { "asp-file-version", "true" }
+ });
+ var output = MakeImageTagHelperOutput(
+ attributes: new TagHelperAttributeList
+ {
+ { "alt", new HtmlString("alt text") },
+ { "data-extra", new HtmlString("something") },
+ { "title", new HtmlString("Image title") },
+ { "src", "testimage.png" },
+ { "asp-file-version", "true" }
@dougbu
dougbu May 10, 2015 Member

Bit unrealistic. src and asp-file-version are not in the TagHelperOutput.Attributes collection by default. Bound attributes appear only in the TagHelperExecutionContext.AllAttributes collection when tag helper execution begins. That's why the CopyHtmlAttribute() call is necessary in the <img> tag helper.

@dougbu
dougbu May 11, 2015 Member

Thanks. output looks good now.

@dougbu dougbu commented on the diff May 10, 2015
...soft.AspNet.Mvc.TagHelpers.Test/ImageTagHelperTest.cs
+ { "alt", new HtmlString("alt text") },
+ { "src", "/bar/images/image.jpg" },
+ { "asp-file-version", "true" },
+ });
+ var output = MakeImageTagHelperOutput(attributes: new TagHelperAttributeList
+ {
+ { "alt", new HtmlString("alt text") },
+ });
+ var hostingEnvironment = MakeHostingEnvironment();
+ var viewContext = MakeViewContext("/bar");
+ var helper = new ImageTagHelper
+ {
+ HostingEnvironment = hostingEnvironment,
+ ViewContext = viewContext,
+ Src = "/bar/images/image.jpg",
+ FileVersion = true,
@dougbu
dougbu May 10, 2015 Member

Need a test with FileVersion == false to confirm CopyHtmlAttribute() is called correctly.

@NTaylorMullen
Member

⌚️

@dougbu dougbu commented on an outdated diff May 10, 2015
...soft.AspNet.Mvc.TagHelpers.Test/ImageTagHelperTest.cs
+ {
+ { "alt", new HtmlString("alt text") },
+ { "data-extra", new HtmlString("something") },
+ { "title", new HtmlString("Image title") },
+ { "src", "testimage.png" },
+ { "asp-file-version", "true" }
+ });
+
+ var expectedOutput = MakeImageTagHelperOutput(
+ attributes: new TagHelperAttributeList
+ {
+ { "alt", new HtmlString("alt text") },
+ { "data-extra", new HtmlString("something") },
+ { "title", new HtmlString("Image title") },
+ { "src", "testimage.png?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk" },
+ { "asp-file-version", "true" }
@dougbu
dougbu May 10, 2015 Member

in realistic scenario asp-file-version would not appear in the Attributes collection after processing

@dougbu dougbu commented on an outdated diff May 10, 2015
...soft.AspNet.Mvc.TagHelpers.Test/ImageTagHelperTest.cs
+ {
+ HostingEnvironment = hostingEnvironment,
+ ViewContext = viewContext,
+ Src = "/images/test-image.png",
+ FileVersion = true,
+ Cache = MakeCache(),
+ };
+
+ // Act
+ helper.Process(context, output);
+
+ // Assert
+ Assert.True(output.Content.IsEmpty);
+ Assert.Equal("img", output.TagName);
+ Assert.Equal(2, output.Attributes.Count);
+ TagHelperAttribute srcAttribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("src"));
@dougbu dougbu and 1 other commented on an outdated diff May 10, 2015
...soft.AspNet.Mvc.TagHelpers.Test/ImageTagHelperTest.cs
+ var helper = new ImageTagHelper
+ {
+ HostingEnvironment = hostingEnvironment,
+ ViewContext = viewContext,
+ Src = "/bar/images/image.jpg",
+ FileVersion = true,
+ Cache = MakeCache(),
+ };
+
+ // Act
+ helper.Process(context, output);
+ // Assert
+ Assert.True(output.Content.IsEmpty);
+ Assert.Equal("img", output.TagName);
+ Assert.Equal(2, output.Attributes.Count);
+ TagHelperAttribute srcAttribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("src"));
@dpaquette
dpaquette May 10, 2015 Contributor

just to confirm...we can use var in tests but shouldn't in other code?

@dougbu
dougbu May 10, 2015 Member

No. Our Guidelines say "The var keyword is to be used as much as the compiler will allow." (Everywhere.)

@dpaquette
dpaquette May 10, 2015 Contributor

My bad. For some reason I read that part of the guideline as 'is not to be used'.

@dougbu dougbu commented on an outdated diff May 10, 2015
...soft.AspNet.Mvc.TagHelpers.Test/ImageTagHelperTest.cs
+
+ var metadataProvider = new EmptyModelMetadataProvider();
+ var viewData = new ViewDataDictionary(metadataProvider);
+ var viewContext = new ViewContext(
+ actionContext,
+ Mock.Of<IView>(),
+ viewData,
+ Mock.Of<ITempDataDictionary>(),
+ TextWriter.Null);
+
+ return viewContext;
+ }
+
+ private static TagHelperContext MakeTagHelperContext(
+ TagHelperAttributeList attributes = null,
+ string content = null)
@dougbu
dougbu May 10, 2015 Member

Simplify method signature: No need for attributes to be optional. No need for content at all.

@dougbu dougbu commented on an outdated diff May 10, 2015
...soft.AspNet.Mvc.TagHelpers.Test/ImageTagHelperTest.cs
+ {
+ attributes = attributes ?? new TagHelperAttributeList();
+
+ return new TagHelperContext(
+ attributes,
+ items: new Dictionary<object, object>(),
+ uniqueId: Guid.NewGuid().ToString("N"),
+ getChildContentAsync: () =>
+ {
+ var tagHelperContent = new DefaultTagHelperContent();
+ tagHelperContent.SetContent(content);
+ return Task.FromResult<TagHelperContent>(tagHelperContent);
+ });
+ }
+
+ private static TagHelperOutput MakeImageTagHelperOutput(TagHelperAttributeList attributes = null)
@dougbu
dougbu May 10, 2015 Member

No need for attributes to be optional.

@dougbu dougbu and 1 other commented on an outdated diff May 10, 2015
...soft.AspNet.Mvc.TagHelpers.Test/ImageTagHelperTest.cs
+ mockFile.SetupGet(f => f.Exists).Returns(true);
+ mockFile
+ .Setup(m => m.CreateReadStream())
+ .Returns(() => new MemoryStream(Encoding.UTF8.GetBytes("Hello World!")));
+ var mockFileProvider = new Mock<IFileProvider>();
+ mockFileProvider.Setup(fp => fp.GetDirectoryContents(It.IsAny<string>()))
+ .Returns(emptyDirectoryContents.Object);
+ mockFileProvider.Setup(fp => fp.GetFileInfo(It.IsAny<string>()))
+ .Returns(mockFile.Object);
+ var hostingEnvironment = new Mock<IHostingEnvironment>();
+ hostingEnvironment.Setup(h => h.WebRootFileProvider).Returns(mockFileProvider.Object);
+
+ return hostingEnvironment.Object;
+ }
+
+ private static IApplicationEnvironment MakeApplicationEnvironment(string applicationName = "testApplication")
@dougbu
dougbu May 10, 2015 Member

Unused; remove.

@dpaquette
dpaquette May 10, 2015 Contributor

I'm wondering what this. It is also unused in the test for the Link tag helper

@dougbu
dougbu May 10, 2015 Member

Might have been needed at some point there. But you're not using it here.

@dougbu
dougbu May 10, 2015 Member

Please remove this method.

@dougbu dougbu commented on an outdated diff May 10, 2015
...soft.AspNet.Mvc.TagHelpers.Test/ImageTagHelperTest.cs
+ mockFileProvider.Setup(fp => fp.GetFileInfo(It.IsAny<string>()))
+ .Returns(mockFile.Object);
+ var hostingEnvironment = new Mock<IHostingEnvironment>();
+ hostingEnvironment.Setup(h => h.WebRootFileProvider).Returns(mockFileProvider.Object);
+
+ return hostingEnvironment.Object;
+ }
+
+ private static IApplicationEnvironment MakeApplicationEnvironment(string applicationName = "testApplication")
+ {
+ var applicationEnvironment = new Mock<IApplicationEnvironment>();
+ applicationEnvironment.Setup(a => a.ApplicationName).Returns(applicationName);
+ return applicationEnvironment.Object;
+ }
+
+ private static IMemoryCache MakeCache(object result = null)
@dougbu
dougbu May 10, 2015 Member

Remove result parameter. No caller passes an argument.

@dougbu
Member
dougbu commented May 10, 2015

⌚️ very close

@dpaquette
Contributor

@dougbu @NTaylorMullen Thanks for the review. I have updated based on your feedback. In retrospect, basing this implementation on the Link and Script Tag Helpers was probably a bad idea 😄

@dougbu dougbu commented on the diff May 10, 2015
...soft.AspNet.Mvc.TagHelpers.Test/ImageTagHelperTest.cs
+using Microsoft.AspNet.Hosting;
+using Microsoft.AspNet.Http.Internal;
+using Microsoft.AspNet.Mvc.ModelBinding;
+using Microsoft.AspNet.Mvc.Rendering;
+using Microsoft.AspNet.Razor.Runtime.TagHelpers;
+using Microsoft.AspNet.Routing;
+using Microsoft.Framework.Caching;
+using Microsoft.Framework.Caching.Memory;
+using Microsoft.Framework.Runtime;
+using Moq;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
@dougbu
dougbu May 10, 2015 Member

Sorry, should have mentioned that we use the old VS default here: System namespaces first.

@dougbu
dougbu May 11, 2015 Member

Thanks

@dougbu
Member
dougbu commented May 10, 2015

⌚️

@dougbu dougbu commented on the diff May 11, 2015
...osoft.AspNet.Mvc.FunctionalTests/MvcTagHelpersTest.cs
@@ -47,6 +47,8 @@ public class MvcTagHelpersTest
[InlineData("Link", null)]
// Testing the ScriptTagHelper
[InlineData("Script", null)]
+ // Testing the ImageTagHelper
+ [InlineData("Image", null)]
@dougbu
dougbu May 11, 2015 Member

Odd that MvcTagHelpersWebSite.MvcTagHelper_Home.Image.html shows up here as a binary file. Anything unusual about it on your end? (Content looks fine when I click on View.)

@dpaquette
dpaquette May 11, 2015 Contributor

Looks line an encoding problem. I will try saving as UTF-8

@dougbu
Member
dougbu commented May 11, 2015

:shipit:

Please rebase your branch to latest dev then squash your commits down to one (git rebase -i head~8 and change pick to s or squash for all commits except the first. We won't lose attribution when merging if you do that.

@NTaylorMullen NTaylorMullen commented on an outdated diff May 11, 2015
src/Microsoft.AspNet.Mvc.TagHelpers/ImageTagHelper.cs
+ [Activate]
+ [HtmlAttributeNotBound]
+ public IHostingEnvironment HostingEnvironment { get; set; }
+
+ [Activate]
+ [HtmlAttributeNotBound]
+ public ViewContext ViewContext { get; set; }
+
+ [Activate]
+ [HtmlAttributeNotBound]
+ public IMemoryCache Cache { get; set; }
+
+ /// <inheritdoc />
+ public override void Process(TagHelperContext context, TagHelperOutput output)
+ {
+ if (FileVersion == true)
@NTaylorMullen
NTaylorMullen May 11, 2015 Member

if (FileVersion)

@NTaylorMullen
Member

:shipit:

@dpaquette dpaquette ImageTagHelper
An ImageTagHelper that supports cache busting by appending a file
version hash to the image src attribute
[Resolves #2249]

Code cleanup
ab4d2ee
@dpaquette
Contributor

@dougbu @NTaylorMullen Thanks guys. I did a rebase to latest dev and squashed my commits.

@Eilon
Member
Eilon commented May 11, 2015

BTW I logged #2540 to track changing the name of the FileVersion property.

@dougbu dougbu merged commit ab4d2ee into aspnet:dev May 11, 2015

0 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
continuous-integration/appveyor Waiting for AppVeyor build to complete
Details
@dougbu
Member
dougbu commented May 11, 2015

ab4d2ee Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment