I'm installing the Azure CDN Toolkit for the first time, and I'm struggling to gain access the Helper methods inside my strongly typed object model.
I can see the extensions are contained inside "Our.Umbraco.AzureCDNToolkit.UrlHelperRenderExtensions" however, I can't figure out how to get this context into my C# code.
namespace client.project.Logic.Model.Media
{
public class Image : BaseContentType
{
public Image(IPublishedContent content)
: base(content)
{
}
public string Url
{
get
{
return this.GetCropUrl(imageCropMode: ImageCropMode.Max, width: 1200);
}
}
}
}
It's an interesting one with moving the helpers in Umbraco to HtmlHelper and UrlHelper extension methods rather than IPublishedContent which I've continued in this package it means you need a helper to use the methods in this context.
I would go with this.
public abstract class BaseContentType : PublishedContentModel
{
private UmbracoHelper _umbracoHelper;
internal UrlHelper UrlHelper;
protected BaseContentType(IPublishedContent content)
: base(content)
{
_umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
UrlHelper = new UrlHelper();
}
and then
public class Image : BaseContentType
{
public Image(IPublishedContent content) : base(content)
{
}
public string Url
{
get
{
return this.UrlHelper.GetCropCdnUrl(this.Content, imageCropMode: ImageCropMode.Max, width: 1200).ToString();
}
}
}
I will think about adding methods that aren't extension methods to this package as I think they are useful on their own for scenarios such as this...
Just having some issues with the ImageProcessor part of it >.<
Using the latest (AzureBlobCache.1.1.2.0) as my storage is in the UK.
Have checked all the DLL's are present, and versions are correct, triple checked config files!
System.MissingMethodException: Method not found: 'System.String ImageProcessor.Web.Helpers.ImageHelpers.GetExtension(System.String, System.String)'.
at ImageProcessor.Web.Plugins.AzureBlobCache.AzureBlobCache.<CreateCachedFileNameAsync>d__24.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
at ImageProcessor.Web.Plugins.AzureBlobCache.AzureBlobCache.CreateCachedFileNameAsync()
at ImageProcessor.Web.Plugins.AzureBlobCache.AzureBlobCache.<IsNewOrUpdatedAsync>d__2.MoveNext()
Accessing Helper Methods
Hey!
I'm installing the Azure CDN Toolkit for the first time, and I'm struggling to gain access the Helper methods inside my strongly typed object model.
I can see the extensions are contained inside "Our.Umbraco.AzureCDNToolkit.UrlHelperRenderExtensions" however, I can't figure out how to get this context into my C# code.
What do you have in your BaseContentType?
Here we go, a few helpers and a way of bringing back Typed Media/Content.
It's an interesting one with moving the helpers in Umbraco to HtmlHelper and UrlHelper extension methods rather than IPublishedContent which I've continued in this package it means you need a helper to use the methods in this context.
I would go with this.
and then
I will think about adding methods that aren't extension methods to this package as I think they are useful on their own for scenarios such as this...
Thanks Jeavon! I've successfully implemented everywhere, just waiting for the blobs to be available on the CDN endpoint :-) Thanks! Laurie
Cool, it can take quite a few hours before they appear, it says 90 minutes but I've never seen it be that quick!
This helped me since I have code outside of Razor views where I want to return Crops from the CDN and came unstuck! Thanks
The files are there now!
Just having some issues with the ImageProcessor part of it >.<
Using the latest (AzureBlobCache.1.1.2.0) as my storage is in the UK.
Have checked all the DLL's are present, and versions are correct, triple checked config files!
Odd, could you try updating the WindowsAzure.Storage NuGet package to the latest (I have a hunch something's slightly different with new UK accounts)?
To double check you have the following versions?
Updating WindowsAzure.Storage from 6.2.0 to 7.2.1 resolved this issue.
Oh wow!
Yep! Thanks again :-) Looking forward to Slimsy v2
is working on a reply...