Copied to clipboard

Flag this post as spam?

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


  • Lasse Kofoed 49 posts 177 karma points
    Apr 26, 2019 @ 14:33
    Lasse Kofoed
    0

    7.14.0 Attachment Media crop bug ( with workaround )

    Attactments with 7.14 not working error with crop

    listOfAttachments.Add(new PerplexMail.Attachment(4242)); // Umbraco media node id not working with crop
    

    Exception: System.Web.HttpException (0x80004005): '~{"src": "/media/1350/1436-image.png", "crops": [ //{"alias": "Navigation","width": 200,"height": 200

    I fixed it by doing the following

    // Using direct filepath as workaround

    var _mediaService = ApplicationContext.Current.Services.MediaService;
    var media = _mediaService.GetById(4242);
    var umbracoFilePath = media.GetValue<string>(Umbraco.Core.Constants.Conventions.Media.File);
    var path = HttpContext.Current.Server.MapPath(JsonConvert.DeserializeObject<ImageCropDataSet>(umbracoFilePath).Src);
    
    listOfAttachments.Add(new PerplexMail.Attachment(path));
    
Please Sign in or register to post replies

Write your reply to:

Draft