Reputation: 265
I am using following line of code to render image:
string html = Sitecore.Web.UI.WebControls.FieldRenderer.Render(
Item,
this.Field,
renderParameters + "&disable-web-editing=" + this.DisableWebEditing.ToString());
Following string is assigned in html:
<img src="http://localhost/~/assets/images/widgets/contact.png?bc=White&h=130&la=en&w=130" width="130" height="130" />
Is there any way so that src
of image is relative path?
Upvotes: 2
Views: 408
Reputation: 27132
Assuming that your application doesn't have any customizations, FieldRenderer
uses MediaUrlOptions
to know how to generate the url.
MediaUrlOptions
uses Settings.Media.AlwaysIncludeServerUrl
to determine whether the full server url should be included or not.
Check your setting in the configuration and set it to proper value:
<!-- MEDIA ALWAYS INCLUDE SERVER URL
If true, Sitecore will generate absolute URLs when it uses the MediaProvider API and/or the link provider to render media URLs.
If blank, Sitecore will use the same value as the alwaysIncludeServerUrl attribute from the link provider.
Default value: "" (use the value from the link provider)
-->
<setting name="Media.AlwaysIncludeServerUrl" value="" />
Upvotes: 1