Copied to clipboard

Flag this post as spam?

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


  • Bent Holz 100 posts 273 karma points
    Oct 24, 2011 @ 10:39
    Bent Holz
    0

    How to get image width and height using Upload?

    Trying to make a list of images with Xslt and the Upload function on my doctype...

    The list works fine in say Google Chrome but not in IE9 because it needs the width and height of the images.

    Does the upload-function not store these informations and only the image or can i somehow get these values into my Xstl?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 24, 2011 @ 14:49
    Dirk De Grave
    0

    nope, it's not stored, only the file reference is stored... so you'd need to either store it on the media section and use a media picker to reference the media item, or get the info dynamically using the Bitmap class.

    Last solution will be overkill, unless you wire up an even that fires when saving/publishing a doc that holds the upload field and add some additional image info such as width and height as labels on your doc type.

     

    Cheers,

    /Dirk

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Oct 24, 2011 @ 14:55
    Lee Kelleher
    1

    Hi Crawn,

    If you add the following properties to your document-type, then Umbraco will auto-populate them:

    umbracoExtension, umbracoBytes, umbracoWidth, umbracoHeight

    This is how it works for the Image media-type.

    Cheers, Lee.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 24, 2011 @ 14:57
    Dirk De Grave
    0

    Doh, should've known that one... Big thanks for reminding me Lee :D

     

    Cheers,

    /Dirk

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Oct 24, 2011 @ 15:01
    Lee Kelleher
    0

    No worries Dirk... I cracked open Reflector to double-check! ;-)

    ... another one to throw out there.  In the uComponents XsltExtension for Media, we have a few methods:

    <xsl:value-of select="ucomponents.media:GetImageHtml(mediaId)" disable-output-escaping="yes" />

    or to get the height/width directly, use these:

    Height: <xsl:value-of select="ucomponents.media:GetImageHeight(imagePath)" />
    Width: <xsl:value-of select="ucomponents.media:GetImageWidth(imagePath)" />

    Cheers, Lee.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 24, 2011 @ 15:05
    Dirk De Grave
    1

    @Lee, sounds ok to get width and height for just one pic, but not if that's inside a loop, seems to be some overkill to do so many io operations on the bitmap...

     

    Cheers,

    /Dirk

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Oct 24, 2011 @ 15:07
    Lee Kelleher
    0

    I wholeheartedly agree!  I'd go with the "umbraco*" alias prefixes, stored the data at upload/save time.

  • Bent Holz 100 posts 273 karma points
    Oct 24, 2011 @ 19:14
    Bent Holz
    0

    Hi...

    So on my document type with the property "image" (upload) i just add "umbracoExtension", "umbracoBytes", "umbracoWidth" and "umbracoHeight" properties?

    What type do I select for each of those?

    Ye... I'm new at this, but as i learn, Umbraco gets more and more awesome... like double-rainbow-awesome...

    Thx for your time....

    Cheers

    Crawn

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 24, 2011 @ 19:40
    Dirk De Grave
    0

    Have a look at the image media type in the settings section, you must copy alias and type, name can be anything for each of the umbraco* properties.

     

    Cheers,

    /Dirk

  • Bent Holz 100 posts 273 karma points
    Oct 24, 2011 @ 22:19
    Bent Holz
    0

    Bloody awesome, thx guys... so very simple...  when you know it!

    Thx!...

    Cheers

    Crawn

Please Sign in or register to post replies

Write your reply to:

Draft