Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mitton 22 posts 71 karma points c-trib
    Oct 27, 2014 @ 04:31
    Mitton
    0

    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?

  • Mitton 22 posts 71 karma points c-trib
    Oct 27, 2014 @ 04:38
    Mitton
    0

    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?

  • Mitton 22 posts 71 karma points c-trib
    Oct 27, 2014 @ 05:15
    Mitton
    0

    Maybe the GetCropUrl extension method should extent ContentBase instead?

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Oct 27, 2014 @ 10:25
    Jeavon Leopold
    0

    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:

    var typedMember = Umbraco.TypedMember(123545);
    var cropUrl = typedMember.GetCropUrl(100, 100);
    

    Jeavon

  • Tobias Klika 101 posts 570 karma points c-trib
    Oct 27, 2014 @ 10:25
    Tobias Klika
    100

    If you use UmbracoHelper.TypedMember you can get the IPublishedContent ;-)

  • Mitton 22 posts 71 karma points c-trib
    Oct 27, 2014 @ 10:57
    Mitton
    0

    Jeavon and Tobias, thank you so much. You are life savers!

  • Fredrik 7 posts 38 karma points
    Feb 10, 2015 @ 11:13
    Fredrik
    0

    In my controller .GetCropUrl() dosen't exist with Umbraco.TypedMember() any ideas? Is it because it's a surfacecontroller with custom model?

    public class UserController : SurfaceController
    {
        public ActionResult ForgotPassword() 
        {
            return View("ForgotPassword");
        }
    
        public ActionResult ResetPassword()
        {
            return View("ResetPassword");
        }
    
        public ActionResult RenderProfile(string profileUrl)
        {
            var memberService = Services.MemberService;
            var findMember = memberService.GetAllMembers().FirstOrDefault(x => x.GetValue("profileUrl").ToString() == profileUrl);
    
            var profile = new ProfileModel();
    
            if (findMember != null)
            {
                var typedMember = Umbraco.TypedMember(findMember.Id);
                profile.Name = findMember.Name;
                profile.Email = findMember.Email;
                profile.MemberType = memberService.GetAllRoles(findMember.Username).FirstOrDefault();
                profile.Description = findMember.GetValue("presentationText").ToString();
                profile.Youtube = findMember.GetValue("youtube").ToString();
                profile.Skype = findMember.GetValue("skype").ToString();
                profile.Twitter = findMember.GetValue("twitter").ToString();
                profile.PresentationImage = typedMember.?
            }
            else
            {
                return new HttpNotFoundResult("The member profile does not exist");
            }
            return View("Profile", profile);
        }
    }
    
  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Feb 10, 2015 @ 12:17
    Jeavon Leopold
    0

    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;
            }
        }
    }
    
  • Fredrik 7 posts 38 karma points
    Feb 10, 2015 @ 13:07
    Fredrik
    0

    Solved the problem, thanks Jeavon!

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Feb 10, 2015 @ 16:03
    Jeavon Leopold
    0

    No problem :)

  • von 61 posts 123 karma points
    Mar 19, 2015 @ 12:48
    von
    0

    I am using version 7.2.2 and doing a Umbraco.TypedMember(id).GetCropUrl(cropAlias) throws a NotSupportedException. Is this a known issue?

  • Simon Kibsgård 62 posts 73 karma points
    Aug 29, 2015 @ 23:05
    Simon Kibsgård
    0

    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

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Aug 30, 2015 @ 15:27
    Jeavon Leopold
    0

    Hi Simon,

    @Umbraco.TypedMember(id).GetCropUrl(propertyAlias, cropAlias) should work fine...?

    Jeavon

  • Simon Kibsgård 62 posts 73 karma points
    Aug 30, 2015 @ 15:38
    Simon Kibsgård
    0

    Hi Jerome Thnx, for helping out. I have tried that approach, but get this:

    Exception: System.Exception: 'Umbraco.Web.PublishedCache.MemberPublishedContent' does not contain a definition for 'GetCropUrl'

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Aug 30, 2015 @ 17:00
    Jeavon Leopold
    0

    Strange, I just double checked with Umbraco v7.2.2 and this works fine

    var profilePicture = Umbraco.TypedMember(1084).GetCropUrl("profilePicture", "home");
    

    What version of Umbraco are you using?

    Is your code in a view, controller or other?

    Jeavon

Please Sign in or register to post replies

Write your reply to:

Draft