Copied to clipboard

Flag this post as spam?

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


  • Thomas Nielsen 4 posts 24 karma points
    Sep 21, 2012 @ 15:52
    Thomas Nielsen
    0

    Get Width and height from Upload type in Razor

    Hi I am using a Upload type in my Umbraco 4.9 solution, and want to display a picture and its width/heigt.

    I use @Model.reelFrontImage to display the image it self, but can not figure out how to get the width and height - anybody who knows?

    Thanks in advance :)

    Thomas

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Sep 21, 2012 @ 17:16
    Tom Fulton
    1

    Hi Thomas,

    The Upload field doesn't store this info, only if you're using the Media Library.  But if you're using uComponents there are a few XSLT Helper functions that I thnk you can use in Razor also.  See the docs here, they have GetImageWidth(path) and GetImageHeight(path)

    I think in Razor you could do this:

    uComponents 4.x:

    uComponents.Core.XsltExtensions.Media.GetImageHeight(@Model.reelFrontImage)

    uComponents 5.x:

    uComponents.XsltExtensions.Media.GetImageHeight(@Model.reelFrontImage)

    Hope this helps,
    Tom 

  • Thomas Nielsen 4 posts 24 karma points
    Sep 22, 2012 @ 09:34
    Thomas Nielsen
    0

    Perfect, works like a charm :)

    Thank you so much 

Please Sign in or register to post replies

Write your reply to:

Draft