It seems the problem is that GetCropUrl is an extension method on IPublishedContent, but Umbraco.Core.Models.Member does not implement the interface IPublishedContent.
So what do?
I can get the JSON string for the imagecropper, but isn't there a better way?
You should be able to but will require a using Umbraco.Web;
Just tried with this controller:
namespace SomethingElse
{
using System.Web.Mvc;
using Umbraco.Web;
using Umbraco.Web.Mvc;
public class UserController : SurfaceController
{
public ActionResult Something()
{
var a = Umbraco.TypedMember(2323).GetCropUrl();
return null;
}
}
}
I have the same issues trying to use image cropper property on member. In your examples I believe the customer property name of the image cropper is not defined?
Does anyone have a working example retrieving an image cropper property from a member?
Thnx, Simon
GetCropUrl on member
My member type has an ImageCropper property. However, I can't access the GetCropUrl method on the member type.
I also tried casting the member object as a DynamicPublishedContent, but that just gives me a null object.
How can I access the crop URL from an image cropper property on a member?
It seems the problem is that GetCropUrl is an extension method on IPublishedContent, but Umbraco.Core.Models.Member does not implement the interface IPublishedContent.
So what do?
I can get the JSON string for the imagecropper, but isn't there a better way?
Maybe the GetCropUrl extension method should extent ContentBase instead?
Hi Mitton,
You can get member data as IPublishedContent, the advantage over Member is that the data is cached however it's of course read only.
Depending on your existing code, you could do this:
Jeavon
If you use
UmbracoHelper.TypedMember
you can get theIPublishedContent
;-)Jeavon and Tobias, thank you so much. You are life savers!
In my controller .GetCropUrl() dosen't exist with Umbraco.TypedMember() any ideas? Is it because it's a surfacecontroller with custom model?
You should be able to but will require a
using Umbraco.Web;
Just tried with this controller:
Solved the problem, thanks Jeavon!
No problem :)
I am using version 7.2.2 and doing a Umbraco.TypedMember(id).GetCropUrl(cropAlias) throws a NotSupportedException. Is this a known issue?
I have the same issues trying to use image cropper property on member. In your examples I believe the customer property name of the image cropper is not defined? Does anyone have a working example retrieving an image cropper property from a member? Thnx, Simon
Hi Simon,
@Umbraco.TypedMember(id).GetCropUrl(propertyAlias, cropAlias)
should work fine...?Jeavon
Hi Jerome Thnx, for helping out. I have tried that approach, but get this:
Strange, I just double checked with Umbraco v7.2.2 and this works fine
What version of Umbraco are you using?
Is your code in a view, controller or other?
Jeavon
is working on a reply...