Copied to clipboard

Flag this post as spam?

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


  • Sean 141 posts 179 karma points
    Apr 26, 2011 @ 01:27
    Sean
    0

    media assets showing, height and width are empty?

    Hi There,

    I'm using the image cropper to define the image properties that I have. All of these images have height and width but only the image is displaying, the height and width are empty.

    I'm not sure what i'm missing from my XSLT. Can someone help me out with the syntax please?

    Thanks in advance.

    Sean

     

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:msxml="urn:schemas-microsoft-com:xslt"
        xmlns:umbraco.library="urn:umbraco.library"
        exclude-result-prefixes="msxml umbraco.library">
    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <xsl:template match="/">
          <xsl:variable name="mediaId" select="number($currentPage/imageRightPromo)" />
          <xsl:if test="$mediaId > 0">
              <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />
              <xsl:if test="$mediaNode/umbracoFile">
                  <img src="{$mediaNode/umbracoFile}" alt="[image]" height="{umbracoHeight}" width="{umbracoWidth}" />
              </xsl:if>
          </xsl:if>
    </xsl:template>
    </xsl:stylesheet>

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 26, 2011 @ 03:51
    Tom Fulton
    0

    Hi Sean,

    It looks like the properties (umbracoHeight, umbracoWidth) are missing the $mediaNode variable before them, try:

     <img src="{$mediaNode/umbracoFile}" alt="[image]" height="{$mediaNode/umbracoHeight}" width="{$mediaNode/umbracoWidth}" />

    -Tom

  • Sean 141 posts 179 karma points
    Apr 26, 2011 @ 04:18
    Sean
    0

    Hi Tom, that does not seem to work at all. They are still showing as:

    Are they stored in a file or db when they are uploaded?

    <img height="" width="" alt="[image]" src="/media/5022/image.jpg">

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 26, 2011 @ 04:57
    Tom Fulton
    0

    Hmm, that's odd.  They are stored as properties on the media node itself, just like a property on a document.  Try going to the Media section, finding that image and seeing if the Height & Width are filled out there.  Or is this perhaps a custom media type?  If so you'll need to add the properties manually (see the Image media type for the list of them).

    If they are showing in the backoffice correctly, try adding this right before the <img> tag, this will dump out the media's raw XML and you can see if the properties are filled out there.

    <textarea><xsl:copy-of select="$mediaNode"/></textarea>

    -Tom

  • Sean 141 posts 179 karma points
    Apr 26, 2011 @ 05:24
    Sean
    0

    Hi Tom,

    That's a really great trick. I must have been looking at the wrong image. Worked like a treat.

    Thanks again

     

    <Image id="1269" version="fcc1a439-03b8-4109-839f-e6cfd624e799" parentID="-1" level="1" writerID="0" nodeType="1032" template="0" sortOrder="85" createDate="2011-04-06T17:56:44" updateDate="2011-04-06T17:56:43" nodeName="imageFeatureSecondFromLeft" urlName="imagefeaturesecondfromleft" writerName="admin" nodeTypeAlias="Image" path="-1,1269"><umbracoFile>/media/2874/image.jpg</umbracoFile><umbracoWidth>170</umbracoWidth><umbracoHeight>116</umbracoHeight><umbracoBytes>12401</umbracoBytes><umbracoExtension>jpg</umbracoExtension><imageCropper></imageCropper></Image>

     

Please Sign in or register to post replies

Write your reply to:

Draft