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:Itemrunat="server"field="mediaItem"xslt="concat('<img src="',umbraco.library:GetMedia({0},'true')/data[@alias='umbracoFile'], '" />')"xsltDisableEscaping="true"/>
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
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('<img src="',umbraco.library:GetMedia({0},'true')/data[@alias='umbracoFile'], '" />')" xsltDisableEscaping="true"/>
... but how do I insert it in a variable??
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('<img src="',umbraco.library:GetMedia({0},'true')/data[@alias='umbracoFile'], '" />')" 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.
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
table style="background-image-url:<umbraco:Item runat="server" field="mediaItem" xslt="concat('<img src="',umbraco.library:GetMedia({0},'true')/data[@alias='umbracoFile'], '" />')" 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" />
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
<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>
is working on a reply...