Pushpendra
Pushpendra

Reputation: 174

how to use umbraco field in xslt file

I want to add my umbraco field in xslt file, how can i do this.

my umbraco field is:

<umbraco:Item field="image" useIfEmpty="image" textIfEmpty="/css/images/dog.jpg" runat="server" />

and i want to use this field in XSLT file in image src field

    <div class="imgbox">
                        <xsl:variable name="image" select="$post/image"/>


                        <img src="/css/images/dog.jpg" alt="" />
</div>

How can i add this field in image src.

Upvotes: 0

Views: 474

Answers (1)

Martijn van der Put
Martijn van der Put

Reputation: 4082

I'm not sure what you mean, but if you want to show the value of the variable "image" in the source of your image, you don't need the extra variable "image" and can directly call the code below:

<img src="{$post/image}" alt="" />

It also depends on what kind of fieldtype the ImageField is. The example above is usefull when your imagefield is a textbox with a hardcoded path. If you use a MediaPicker field, you only get the ID of the image back and you need to retrieve the MediaItem:

<xsl:variable name="media" select="umbraco.library:GetMedia($post/image, false)" />
<img src="{$media/umbracoFile}" alt="" />

Upvotes: 2

Related Questions