Copied to clipboard

Flag this post as spam?

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


  • Miguel Martinez Musterd 2 posts 72 karma points
    Sep 09, 2015 @ 13:28
    Miguel Martinez Musterd
    0

    Get image crop url in Umbraco 6.1.6.

    Hi,

    Using Image Cropper, I've got cropping working and now I need to retrieve the crops of an image.

    I can retrieve the crops using @Umbraco.Media(imageRef).crops however this is in DynamicXml format, which I can't seem to do much with.

    @Umbraco.Media(imageRef).crops.Find() doesn't seem to work.

    Regards,

    Miguel

  • jivan thapa 194 posts 681 karma points
    Sep 09, 2015 @ 18:45
    jivan thapa
    0

    This may help you.

    @{
    
        var mediaId = 12312;
        var mediaNode = Umbraco.TypedMedia(mediaId);
    
        var url1 = mediaNode.Url; // url no cropping
        var cropUrl = mediaNode.GetCropUrl("cropAlias"); // by alias, must define on DataType 
        var croUrl1 = mediaNode.GetCropUrl(width: 300, height: 300); // by size
    }
    
  • Miguel Martinez Musterd 2 posts 72 karma points
    Sep 10, 2015 @ 06:42
    Miguel Martinez Musterd
    0

    Thank you for your response!

    However, using GetCropUrl("alias") gives me the following error:

    'Umbraco.Core.Models.IPublishedContent' does not contain a definition for 'GetCropUrl' and no extension method 'GetCropUrl' accepting a first argument of type 'Umbraco.Core.Models.IPublishedContent' could be found (are you missing a using directive or an assembly reference?)
    

    I'm calling the media node using Umbraco.TypedMedia, the same way as in your code.

  • James Jackson-South 489 posts 1747 karma points c-trib
    Dec 16, 2015 @ 20:24
    James Jackson-South
    0

    Hi Miguel,

    What ImageCropper are you using in v6.1.6? is it a custom package?

    The native ImageCropper that utilizes IPublishedContent.GetCropUrl(alias) as suggested by Jivan was added in v7.1.4

    Cheers

    James

Please Sign in or register to post replies

Write your reply to:

Draft