Copied to clipboard

Flag this post as spam?

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


  • Mikkel Johansen 116 posts 291 karma points
    Mar 26, 2015 @ 06:15
    Mikkel Johansen
    0

    ImageCropper - Original image's width and height

    From the awesome ImageCropper I can get the url to the original image with ".Url". But how do I get the height and width of this image?

  • Jan Skovgaard 11263 posts 23588 karma points MVP 8x admin c-trib
    Mar 26, 2015 @ 06:33
    Jan Skovgaard
    0

    Hi Mikkel

    I think that you should be able to do something like

    var image = @Umbraco.Media(1234).GetCropUrl("banner");
    
    @image.height
    

    Does that work?

    /Jan

  • Mikkel Johansen 116 posts 291 karma points
    Mar 26, 2015 @ 06:43
    Mikkel Johansen
    0

    Hi Jan

    Doesn't that give me the height of the banner crop?

    JSON below show the width and height of each crop. BUT only the "src" to the original image, I miss the width and height alongside the "src".
    Right now I'm think that the only way is to hook into the save-event and read the file and then the image's dimensions and finaly save them to a property. 

    { "focalPoint": { "left": 0.23049645390070922, "top": 0.27215189873417722 }, "src": "/media/SampleImages/1063/pic01.jpg", "crops": [ { "alias": "banner", "width": 800, "height": 90 }, { "alias": "highrise", "width": 80, "height": 400 }, { "alias": "thumb", "width": 90, "height": 90 } ] }

     

     

  • Jan Skovgaard 11263 posts 23588 karma points MVP 8x admin c-trib
    Mar 26, 2015 @ 06:48
    Jan Skovgaard
    0

    Hi Mikkel

    Yes - I also thought that it was what you were after. But now I get that you want the original image's dimensions. Not those of the crop. My bad :)

    I don't think it's possible out of the box...unless you just try fetching the image like @Umbraco.Media(1234) perhaps?

    /Jan

  • Mikkel Johansen 116 posts 291 karma points
    Mar 26, 2015 @ 06:52
    Mikkel Johansen
    101

    Ha, why don't I just try the easy solution first!

    Added the two standard properties there is on the "Image" media type: umbracoWidth and umbraco Height

    And just as predicted the width and height is saved to these labels. So the ImageCropper does the magic as the Uploader :-)

    /Mikkel 

  • Travis Schoening 47 posts 172 karma points
    Oct 17, 2017 @ 06:02
    Travis Schoening
    0

    Mikkel,

    I'm looking to get the original width & height... when you say you added the standard properties, where/how exactly did you add those?

    Thanks!

  • Jan Skovgaard 11263 posts 23588 karma points MVP 8x admin c-trib
    Mar 26, 2015 @ 15:56
    Jan Skovgaard
    1

    Because it's hard to notice the forest due to all them damn trees? :)

    Good to see you got it solved - Perhaps it was just a bit too early in the morning :D

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft