Copied to clipboard

Flag this post as spam?

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


  • Patrick 23 posts 83 karma points
    Dec 27, 2013 @ 12:37
    Patrick
    0

    get image dimensions

    I am working on an Umbraco 7.0.1 site but can't figure out how to get the dimensions of an image from a default Media Picker.

    I retrieve the url of the image through: Umbraco.TypedMedia(item.imageSmall).Url and would expect something like Umbraco.TypedMedia(item.imageSmall).UmbracoWidth but that ain't it.

    Can't really find a rectent (v7) example for the above, so any help is appreciated.

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Dec 27, 2013 @ 13:09
    Dennis Aaen
    100

    Hi Patrick,

    Have you tried something like this:

    @{
        if(Model.Content.HasValue("imageSmall")){
            var mediaItem = Umbraco.TypedMedia(Model.Content.GetPropertyValue("imageSmall"));
            <img src="@mediaItem.GetPropertyValue("umbracoFile")" alt="@mediaItem.GetPropertyValue("Name")" width="@mediaItem.GetPropertyValue("umbracoWidth")" height="@mediaItem.GetPropertyValue("umbracoHeight")"/>   
        }  
    }

    The documentation for the media picker can be found here.

    Hope this helps,

    /Dennis

  • Dan 1285 posts 3917 karma points c-trib
    Dec 27, 2013 @ 13:31
    Dan
    0

    Hi Patrick, could it be a casing issue? i.e. Try umbracoWidth instead of UmbracoWidth.

  • Patrick 23 posts 83 karma points
    Dec 27, 2013 @ 14:10
    Patrick
    0

    Thank you Dennis, solved it!

Please Sign in or register to post replies

Write your reply to:

Draft