Copied to clipboard

Flag this post as spam?

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


  • Fredrik Esseen 594 posts 830 karma points
    Oct 07, 2009 @ 20:32
    Fredrik Esseen
    0

    Using Imagegen in inline xslt

    Im trying to add imagegen to an image in inline xslt but suspects that I have a syntax error somewhere:

    <umbraco:Item runat="server" field="imgAlias" xslt="concat('&lt;img src=&quot;/umbraco/imageGen.aspx?image=',umbraco.library:GetMedia({0},'true')/data[@alias='umbracoFile'], '&amp;width=180&amp;constrain=true&quot; /&gt;')" xsltDisableEscaping="true"/>
  • Douglas Robar 3570 posts 4671 karma points MVP ∞ admin c-trib
    Oct 07, 2009 @ 21:25
    Douglas Robar
    0

    That looks pretty good. What do you get for output to your browser's source code when you run this?

    There's a lot of escaping and quote marks to contend with, though. It might be easier and clearer in the end to write a short macro rather than trying to do it all inline?

    cheers,
    doug.

  • Fredrik Esseen 594 posts 830 karma points
    Oct 07, 2009 @ 21:44
    Fredrik Esseen
    0

    I get no output at all which is really annoying :)

    Yes doing a macro would probably be better but how do I best achieve it?

    The user should pick an image with media Picker with preview. So I want the macro to pick up the selected image. How can I do that from my template?

     

  • bob baty-barr 1180 posts 1294 karma points MVP
    Oct 08, 2009 @ 00:11
    bob baty-barr
    1

    don't forget the goofy escaping with the ampersands in the inline calls... --> &amp;amp;

    <umbraco:Item runat="server" field="lowerPageImage" xslt="concat('&lt;img src=&quot;/umbraco/imageGen.ashx?image=',umbraco.library:GetMedia({0},'true')/data[@alias='umbracoFile'], '&amp;amp;width=200&amp;amp;constrain=true&quot; /&gt;')" xsltDisableEscaping="true"/>

  • bob baty-barr 1180 posts 1294 karma points MVP
    Oct 08, 2009 @ 00:14
    bob baty-barr
    0

    also, here is my generic xslt for displaying a media picker 'pageImage' from my docType, on the template...

    <xsl:template match="/">

    <!-- start writing XSLT -->
    <xsl:if test="$currentPage/data [@alias = 'pageImage'] != ''">
        <xsl:variable name="imageNode" select="$currentPage/data[@alias='pageImage']"/>
        <xsl:variable name="imageData" select="umbraco.library:GetMedia($imageNode,0)/data [@alias = 'umbracoFile']"/>
        <img src="/umbraco/imagegen.ashx?image={$imageData}&amp;width=525&amp;constrain=true" />
    </xsl:if>
    </xsl:template>

  • Fredrik Esseen 594 posts 830 karma points
    Oct 08, 2009 @ 08:41
    Fredrik Esseen
    0

    Once again you guys saved me :) It was the ampersandsd that made the trick. Thank you!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies