IMG tag containing a dynamic URL? Options
ferret
Posted: Friday, February 01, 2008 5:35:16 PM

Rank: Enthusiast

Joined: 1/10/2008
Posts: 25
Location: Nottingham, UK
Hi,

I need to put an IMG tag in an XSLT page, but use a dynamic URL for its source.

The following kicks up an error in the XSLT editor within Umbraco:

Code:

<img src="<xsl:value-of select="data [@alias = 'Thumbnail']" />" />


I have looked up loads of things on Google, but can't seem to find the right syntax. I know it's getting upset about the brackets and that it needs escaping but not how to write it properly! :P

thanks in advance,

Nick

Nottingham web design and green hosting - FCS Websites
Umbraco documentation wiki - Come and join in!
Tobbe
Posted: Friday, February 01, 2008 6:24:32 PM
Rank: Devotee

Joined: 7/19/2006
Posts: 97
Hi,

I think you can do it like this. I havn't tested it.


Code:

<img>
  <xsl:attribute name="src">
    <xsl:value-of select="data [@alias = 'Thumbnail']" />
  </xsl:attribute>
</img>


rdcpro
Posted: Saturday, February 02, 2008 7:39:46 AM
Rank: Newbie

Joined: 8/20/2007
Posts: 8
Tobbe wrote:

Hi,

I think you can do it like this. I havn't tested it.


Code:

<img>
  <xsl:attribute name="src">
    <xsl:value-of select="data [@alias = 'Thumbnail']" />
  </xsl:attribute>
</img>





You should also be able to do it using an attribute value template (note the curly braces) like this:

Code:

  <img src="{data [@alias = 'Thumbnail']}" />



Regards,
Mike Sharp
ferret
Posted: Saturday, February 02, 2008 12:39:37 PM

Rank: Enthusiast

Joined: 1/10/2008
Posts: 25
Location: Nottingham, UK
Cheers! I used the second one and it worked a treat :P

Nick


Nottingham web design and green hosting - FCS Websites
Umbraco documentation wiki - Come and join in!
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.