Copied to clipboard

Flag this post as spam?

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


  • Euge 23 posts 130 karma points
    Dec 17, 2015 @ 15:15
    Euge
    0

    Image Cropper broken URL with strongly typed view

    Hi

    I have umbaraco 7.3 and trying to get the image cropper to work with strongly typed view.

    I have a custom media folder type and custom media image type.

    Custom media image type (property alias umbracoFile) has a property of a custom image cropper.

    My document type has a property of type custom media picker that points to the custom image type.

    When I get content in the method below I only get

    "1127?mode=pad&rnd=130948364990000000" for the BannerImageSrc.

    Although 1127 is the node id of the bannerImage. Any ideas?

      private WidgetViewModel GetStuff(IPublishedContent content)
        {
            var viewM = new WidgetViewModel
            {
                Id = content.Id,
                Title = content.Name,
                Url = content.Url,                
                BannerImageSrc = content.GetCropUrl("bannerImage", "bannerCrop")             
    
        };
    
  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Dec 22, 2015 @ 11:46
    Marc Goodson
    1

    Hi Euge

    A couple of things could be going wrong here;

    1) If you've just added the Crop after you uploaded the media item; try going back into Umbraco, opening up the image, and resaving it, to ensure the crop data is there.

    2) Otherwise to troubleshoot this I would get the Media Object back using Umbraco.TypedMedia and use GetCropUrl off of that...

    eg

    var relatedMedia = Umbraco.TypedMedia(content.GetPropertyValue("bannerImage"))
    
    var cropUrl = "";
    if (relatedMedia != null){
    cropUrl = relatedMedia.GetCropUrl("bannerImage");
    {
    
     var viewM = new WidgetViewModel
            {
                Id = content.Id,
                Title = content.Name,
                Url = content.Url,                
                BannerImageSrc = cropUrl
    

    if you get the gist, at least you'll be able to set a breakpoint, and see if the media item is returned etc.....

    cheers

    Marc

  • Euge 23 posts 130 karma points
    Dec 22, 2015 @ 11:48
    Euge
    100

    Nice one Marc

    Works a treat!!

    Beers owed x2

Please Sign in or register to post replies

Write your reply to:

Draft