Copied to clipboard

Flag this post as spam?

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


  • Damien (Slipoch) 62 posts 346 karma points
    Aug 17, 2016 @ 07:09
    Damien (Slipoch)
    0

    Update the image on a member profile programmatically

    How to do the question above, I will also need to delete the old image.

    Below find the delete area of the function, this does not delete the file.

    string OldIMGId = memb.MemberProperties.Find(x => x.Alias == "profilePic").Value.ToString();
                if (OldIMGId != null && OldIMGId != "") 
                {
                    _mediaService.Delete(Umbraco.Media(OldIMGId));
                }
    

    Below find the update image bit, 'pic' is HttpPostedFileBase type, memb is an umbraco MemberProfile type.

            var media = _mediaService.CreateMedia(pic.FileName, folder.Id, "Image");
            media.SetValue(Constants.Conventions.Media.File, pic);
            _mediaService.Save(media);
    
            memb.MemberProperties.Find(x => x.Alias == "profilePic").Value = media.Id;
            Members.UpdateMemberProfile(memb);
    

    Could someone explian how to do this please?

  • Damien (Slipoch) 62 posts 346 karma points
    Aug 18, 2016 @ 01:08
    Damien (Slipoch)
    100

    Ok turns out my methods were working for the save.

    Had to upload the [sitename].dll file to the server as the changes I made were in the controller.

    Delete is still not working though, I will repost as a separate q.,

    le-sigh...

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies