Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Umbraco/Samples and Articles/Macros

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

A macro for getting the url of an image Go to Developer/XSLT Files, create a new xslt file GetImageURL with the following content: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp " "> ]> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:umbraco.library="urn:umbraco.library" exclude-result-prefixes="msxml umbraco.library"> <xsl:output method="xml" omit-xml-declaration="yes" /> <xsl:param name="currentPage"/> <xsl:variable name="imageID" select="/macro/imageID/node/@id"/> <xsl:template match="/"> <xsl:if test="$imageID != ''"> <img> <xsl:attribute name="src"> <xsl:value-of select="umbraco.library:GetMedia($imageID, 'false')/data [@alias = 'umbracoFile']"/> </xsl:attribute> </img> </xsl:if> </xsl:template> </xsl:stylesheet> Now go to Developer/Macros, create a new macro, Get Image URL, giving it the alias GetImageURL. In Use XSLT File, select the XSLT file you just created. On Parameters, add a new parameter with the alias imageID and name Image ID. The type should be set to mediaCurrent and Show should be checked. Save the macro and your home!