Description:I am using following code chunk which is actually generating complete img tag but I only need image url because I have to set only the url in some CSS property.
@foreach (var item in ViewBag.Items)
{
<li class="slide">
<div class="item featured-item1" style='background-image: url(@Html.Sitecore().Field("Image", item));'>
<div class="content">
<h3>@Html.Sitecore().Field("Title", item)</h3>
<div class="buttons-items">
<a href="@Html.Sitecore().Field("BuyNow", item)" class="btn-buy">BUY NOW</a>
<a href="@Html.Sitecore().Field("LearnMore", item)" class="btn-more">LEARN MORE</a>
</div>
</div>
</div>
</li>
}
Posted by: Junaid Aziz | Posted on: Aug 02, 2018
3
I understood your issue, you can get the Image url in sitecore 9 using mvc by the following two line of code.
So your updated code will become some like the following one.
Hope this may help you !!!
Replied by: Tabish Usman | Replied on: Aug 02, 2018