<xsl:variable name="mediaFolder" select="/macro/mediaFolder" /> <xsl:template match="/"> <xsl:if test="($mediaFolder)"> <xsl:variable name="media" select="umb:GetMedia($mediaFolder/Folder/@id, true())" /> <!-- If no errors, this will run the Folder template below --> <xsl:apply-templates select="$media[not(error)]" /> </xsl:if> </xsl:template> <!-- Template for the folder --> <xsl:template match="Folder"> <div id="slider" class="nivoslider"> <!-- Run templates for individual items (just add Media type aliases) --> <xsl:apply-templates select="File | Image" />
</div> </xsl:template> <!-- Template for items - you can create individual templates to render them differently --> <xsl:template match="File | Image"> <img src="{umbracoFile}" title="$title"/>
</xsl:template>
</xsl:stylesheet>
I want to be able to get a title tag for my image, as the NivoSlider uses this Title tag as a caption. Is there anyway to get a title tag from the media section when I upload an image?
Then, if you'd like to give editors a better possibility of describing the images, I'd suggest you find the Media Type (Image, File etc.) in the Settins section and add a Description property (Textstring), which you can then use:
Get image title tag into xslt
Hi all,
I have been making a slider for my webpage and this is what my XSLT looks like so far:
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:umb="urn:umbraco.library"
exclude-result-prefixes="umb"
>
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
<xsl:param name="currentPage" />
<xsl:variable name="mediaFolder" select="/macro/mediaFolder" />
<xsl:template match="/">
<xsl:if test="($mediaFolder)">
<xsl:variable name="media" select="umb:GetMedia($mediaFolder/Folder/@id, true())" />
<!-- If no errors, this will run the Folder template below -->
<xsl:apply-templates select="$media[not(error)]" />
</xsl:if>
</xsl:template>
<!-- Template for the folder -->
<xsl:template match="Folder">
<div id="slider" class="nivoslider">
<!-- Run templates for individual items (just add Media type aliases) -->
<xsl:apply-templates select="File | Image" />
</div>
</xsl:template>
<!-- Template for items - you can create individual templates to render them differently -->
<xsl:template match="File | Image">
<img src="{umbracoFile}" title="$title"/>
</xsl:template>
</xsl:stylesheet>
I want to be able to get a title tag for my image, as the NivoSlider uses this Title tag as a caption. Is there anyway to get a title tag from the media section when I upload an image?
Any help would be appreciated.
Thank you!
Hi Nick,
For starters, you can use @nodeName and get a title that way (you should also add the alt attribute):
Then, if you'd like to give editors a better possibility of describing the images, I'd suggest you find the Media Type (Image, File etc.) in the Settins section and add a Description property (Textstring), which you can then use:
/Chriztian
is working on a reply...