Copied to clipboard

Flag this post as spam?

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


  • nickornotto 403 posts 907 karma points
    May 15, 2013 @ 15:21
    nickornotto
    0

    Macro doesn't see media custom property

    I have set up a custom property for a media image, eg. caption

    But then when I try to use it in a macro:

    <umbraco:Item field="sideImage" Xslt="umbraco.library:GetMedia({0},false())/caption" runat="server" />

    I get nothing displayed.

    I tried to see what date is returned for the image using this:

    <umbraco:Item field="sideImage" Xslt="umbraco.library:GetMedia({0},false())" runat="server" />

    and there seems not be my property value in there - only src, dimensions and ext values are returned.

    I also tried with

    <umbraco:Item field="sideImage" Xslt="umbraco.library:GetMedia({0},true())" runat="server" />

    but no change to what I get.

    Anyone has idea why is that and how I can get the property value?

    Thank you

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    May 15, 2013 @ 16:47
    Alex Skrypnyk
    0

    Hi Eva

    Try to see what will return just: 

     

    <umbraco:Itemfield="sideImage"runat="server"/>

     

  • nickornotto 403 posts 907 karma points
    May 15, 2013 @ 17:22
    nickornotto
    0

    It return mediaId of course ;)

    I need to get the data through GetMedia

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    May 15, 2013 @ 18:40
    Dennis Aaen
    0

    Hi Eva

    From Umbraco 4.11, there is a new control to display images very easy, just like when you output content from the umbraco:item  

    You use it like this:

    <umbraco:Image runat="server" field="sideImage" />

    /Dennis

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    May 16, 2013 @ 00:27
    Dennis Aaen
    0

    Hi Eva,

    If you create an XSLT file with a assoicated macro and inserted the macro on the template instead of include the XSLT in the template you can do it like this to get the caption out.

    <xsl:if test="$currentPage/sideImage != ''">
            <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/sideImage, 0)"/>
           
    <xsl:variable name="src" select="$media/umbracoFile"/>
           
    <xsl:variable name="width" select="$media/umbracoWidth"/>
           
    <xsl:variable name="height" select="$media/umbracoHeight"/>
           
    <img src="{$src}" width="{$width}" height="{$height}"/>
           
    <xsl:value-ofselect="$media/caption"/>
     
    </xsl:if>

    /Dennis

  • nickornotto 403 posts 907 karma points
    May 16, 2013 @ 11:32
    nickornotto
    0

    Thanks Dennis, it's much straightforward with Image control.

    However, I need to display a custom property. I know I can create xslt, it's just a long way round what I need compared to displaying the image itself :(

  • Claushingebjerg 939 posts 2574 karma points
    May 17, 2013 @ 13:44
    Claushingebjerg
    0

    Try this:

    <umbraco:Item field="sideImage" Xslt="umbraco.library:GetMedia({0}/caption)" runat="server" />
  • nickornotto 403 posts 907 karma points
    May 17, 2013 @ 15:18
    nickornotto
    0

    Thanks but it doesn't work either.

  • Claushingebjerg 939 posts 2574 karma points
    May 17, 2013 @ 15:27
    Claushingebjerg
    0

    Sorry i pasted the wrong piece of code

    <umbraco:Item field="sideImage" Xslt="umbraco.library:GetMedia({0},false())/caption" runat="server" />

    works if you have created a field on your media type called "caption". 
    Filled out the filed on the image in the media section.
    Added a media picker to your page with the alias of sideImage and selcted the image with the filled out property.  

  • nickornotto 403 posts 907 karma points
    May 17, 2013 @ 16:04
    nickornotto
    0

    thanks but that's exactly what's not working for me.

    I described it in my first post

  • Claushingebjerg 939 posts 2574 karma points
    May 21, 2013 @ 08:21
    Claushingebjerg
    0

    Are you sure you've done like this:

    1. Add property to image and fill it out

     

     

     

    2. add inline xslt to your template 

    3. Caption renders frontend

     

     

     

     

     

  • nickornotto 403 posts 907 karma points
    May 21, 2013 @ 11:32
    nickornotto
    0

    YES, I AM SURE

    And the data was in the database.

    However I;ve just noticed that I have two similar images and I was just picking up the wrong one which had no caption saved.

    Sorry, and thanks for leading me to that.

  • Claushingebjerg 939 posts 2574 karma points
    May 21, 2013 @ 14:28
    Claushingebjerg
    0

    Cool, good you got it working :)

Please Sign in or register to post replies

Write your reply to:

Draft