Skip to content

Instantly share code, notes, and snippets.

@Jeavon
Created October 31, 2014 18:36
Show Gist options
  • Save Jeavon/0411ca45e20d1c42ec84 to your computer and use it in GitHub Desktop.
Save Jeavon/0411ca45e20d1c42ec84 to your computer and use it in GitHub Desktop.
Wrapper for GetCropUrl to set default bgColor
namespace MyStuff.App_Code
{
using Umbraco.Core.Models;
using Umbraco.Web;
public static class MyHelpers
{
public static string MyGetCropUrl(this IPublishedContent publishedContent, int width, int height)
{
var bgColor = "fff";
return publishedContent.GetCropUrl(width, height, furtherOptions: string.Format("&bgcolor={0}", bgColor));
}
}
}
@inherits UmbracoTemplatePage
@{
var a = Model.Content.MyGetCropUrl(100, 100);
}
<system.web.webPages.razor>
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="Umbraco.Web" />
<add namespace="Umbraco.Core" />
<add namespace="Umbraco.Core.Models" />
<add namespace="Umbraco.Web.Mvc" />
<add namespace="Microsoft.Web.Helpers" />
<add namespace="umbraco" />
<add namespace="Examine" />
<add namespace="MyStuff.App_Code" />
</namespaces>
</pages>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</system.web.webPages.razor>
@Jeavon
Copy link
Author

Jeavon commented Oct 31, 2014

No problem.

That would be a string extension method which you could do but why when you already have the IPublishedContent object?

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