I have a XSLT file that display a PDF from my media directory. I use media picker to attach the pdf to a particular article.
Now, I would like to give the link (to the pdf) the same name as when i named it in the media area. (when i uploaded the file).
As you can see from the following code, i have hard coded the name "Link til PDF" - I want the name to be the same as the file in the media directory. Hope you understand.
What you are doing is the excact same, UNLESS you're calling the GetMedia extension twice. This means that it'll performe slower than Dennis' sugestion.
You've already grabbed the media item-XML in your $mediaNode-variable, so there's no reason to call the extension once more :)
Use Image name as link name... ?
hello,
I have a XSLT file that display a PDF from my media directory. I use media picker to attach the pdf to a particular article.
Now, I would like to give the link (to the pdf) the same name as when i named it in the media area. (when i uploaded the file).
As you can see from the following code, i have hard coded the name "Link til PDF" - I want the name to be the same as the file in the media directory. Hope you understand.
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:variable name="field" select="/macro/field" />
<xsl:variable name="width" select="/macro/cssWidth" />
<xsl:variable name="height" select="/macro/cssHeight" />
<xsl:template match="/">
<xsl:apply-templates select="$currentPage/pdfItem[normalize-space()]" />
</xsl:template>
<xsl:template match="pdfItem">
<xsl:variable name="mediaNode" select="umbraco.library:GetMedia(., false())" />
<xsl:if test="not($mediaNode[error])">
<a href="{$mediaNode/umbracoFile}" width="{$mediaNode/umbracoWidth}" height="{$mediaNode/umbracoHeight}" alt="PDF link" />
Link til PDF
<a/>
</xsl:if>
</xsl:template>
Regards Klaus
Hi Klaus,
I think this will work for you. Try to put this in between the link tag.
/Dennis
Hi Dennis,
Lovely respones... thnaks
I used this one instead <xsl:value-of select="umbraco.library:GetMedia($currentPage/pdfItem, 'false')/@nodeName"/>
/Thanks anyway
/Klaus
Hi Klavs
I'd go for Dennis' suggestion for sure.
What you are doing is the excact same, UNLESS you're calling the GetMedia extension twice. This means that it'll performe slower than Dennis' sugestion.
You've already grabbed the media item-XML in your $mediaNode-variable, so there's no reason to call the extension once more :)
/Kim A
is working on a reply...