質問

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.

役に立ちましたか?

解決

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="" />
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top