Html.Glass().RenderImage(Model, x => x.Logo, new { mw = 200 }, Editable:true) 

The code above outputs an img tag with the full URL including the hashed parameters.

I want a way to get just the URL (without writing a lot of extra code). The purpose of this is to set an inline background image style.

I know the Glass Mapper Image class has a Src property but that just provides the basic URL without the hashed parameters, so the image would be downloaded full size.

1 Answer 1


This will work for the basic params;

@using Sitecore.Resources.Media

<div style="background-image:url(@HashingUtils.ProtectAssetUrl(string.Format("{0}?{1}", Model.Logo.Src, new MediaUrlOptions { MaxWidth = 200 })))">Hello</div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.