Quantcast
Channel: C1 CMS Foundation - Open Source on .NET
Viewing all articles
Browse latest Browse all 2540

New Post: Using an Image Path with a "background-image" attribute in an XSLT Function

$
0
0
Hi.

I need to set the "background-image" for a DIV tag, where the user decides which image is displayed. My problem is, that the ~media(<the image id>) is not resolved properly, when used in my attribute (it works fine for things like URL's, image src attributes etc...).

The XSLT Template looks like this:
<xsl:variable name="TileActionImage">
~/media(<xsl:value-of select="in:inputs/in:result[@name='GetIActionImageFileXml']/IImageFile/@Id" />)
</xsl:variable>
<xsl:attribute-set name="actionimage">
<xsl:attribute name="style">background-image:url('<xsl:value-of select="$TileActionImage" />'); background-repeat:no-repeat; background-position:right bottom;</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="actionurl">
<xsl:attribute name="href">~/page(<xsl:value-of select="in:inputs/in:result[@name='GetIPageXml']/IPage/@Id" />)</xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="in:inputs/in:result[@name='GetIPageXml']/IPage/@Title" /></xsl:attribute>
</xsl:attribute-set>

The XSLT above uses a variable to set the attribute value in the attribute-set. I have tried other ways as well, but the result remains the same.

The Test output for the function looks fine to me. It renders the ~media(<id>) and also a ~page(<id>) reference.

But when I look at the actual source on the page, only the reference to the page has been changed to a real URL. The ~media() reference is not changed:
<div style="background-image:url(~/media(08910365-454f-4ee5-96e6-0402afcd5b2b)); background-repeat:no-repeat; background-position:right bottom;" class="MetroTile teal"><a href="/Blog" title="Blog"><span><p>Create your own Electronic Performance Support System in minutes</p></span></a></div> I have tried both with and without the ' (quote) in the url() of the background-image attribute without luck.

I am probably going about this the wrong way, so I hope there is someone who can tell me how to resolve a media/image path in an attribute like above.

Regards,
Michael

Viewing all articles
Browse latest Browse all 2540

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>