Copied to clipboard

Flag this post as spam?

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


  • Peter Bradsted Bodenhoff 27 posts 47 karma points
    Jan 08, 2010 @ 14:48
    Peter Bradsted Bodenhoff
    0

    Inserting umbraco:item(image) in table-background?

    Hi!

    How do I insert an umbraco:item(image) in the table-background-variable in a template?

    I know how to show an "ordinary" image with this code : <umbraco:Item runat="server" field="mediaItem" xslt="concat('&lt;img src=&quot;',umbraco.library:GetMedia({0},'true')/data[@alias='umbracoFile'], '&quot; /&gt;')" xsltDisableEscaping="true"/>

    ... but how do I insert it in a variable??

  • Shaun 248 posts 475 karma points
    Jan 15, 2010 @ 06:15
    Shaun
    0

    If you want it to appear in a table background I'm guessing you'll need to generate html that looks something like this in teh template

    <table style="background-image-url:whatever.jpg" />

    except it wouldn't look exactly like that as my css is rubbish.

    I've tried putting umbraco tags within html tags and it generally doesn't work.. see below

    <table style="background-image-url:<umbraco:Item runat="server" field="mediaItem" xslt="concat('&lt;img src=&quot;',umbraco.library:GetMedia({0},'true')/data[@alias='umbracoFile'], '&quot; /&gt;')" xsltDisableEscaping="true"/>" />

    so what I generally do is create a macro to do this for me. the macro essentially writes the html out based on criteria you give it.

    <table style="background-image-url:{umbraco.library:GetMedia($currentPage/data [@alias = 'ArtworkImage'], 'false')/data [@alias = 'umbracoFile']}">

     

    There's bound to be a syntax error or three in there, but basically it's pulling the path to teh image from umbraco, the {} allow you to place that umbraco.library:Getmedia call anywhere you like, its rather like <?=blah?> in PHP

  • sudha 1 post 21 karma points
    Mar 20, 2010 @ 07:07
    sudha
    0

    table style="background-image-url:<umbraco:Item runat="server" field="mediaItem" xslt="concat('&lt;img src=&quot;',umbraco.library:GetMedia({0},'true')/data[@alias='umbracoFile'], '&quot; /&gt;')" xsltDisableEscaping="true"/>" />

     

    need to use single quote with in double quotes....

    ex:

    <img src="<umbraco:Item field='Img' useIfEmpty='Img' runat='server'></umbraco:Item>" alt="image" />

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 20, 2010 @ 09:12
    Jan Skovgaard
    0

    Hi Peter

    If you need to insert the image path into a variable you'll need to fetch it using  a XSLT macro where you can declare a variable.

    <xsl:variable name="myImage" select="umbraco.library:GetMedia($currentPage/data [@alias = 'ArtworkImage'], 'false')/data [@alias = 'umbracoFile']" />

    <table style="background:url({$myImage})">

    Hope this is what you are looking for.

    /Jan

  • Janaka Lakmal 25 posts 72 karma points
    Aug 11, 2010 @ 00:30
    Janaka Lakmal
    0

    <xsl:variable name="imgAlias" select="./data [@alias = 'yourImagepath']" />

      <li style="background-image:url({$imgAlias})">

         <a href="{umbraco.library:NiceUrl(@id)}">

          <xsl:value-of select="@nodeName"/>

        </a>

      </li>

Please Sign in or register to post replies

Write your reply to:

Draft