Jordan
Jordan

Reputation: 359

How to stop absolute URL's forming in the Sitecore Image field renderer?

I basically have some items bound to a repeater which have images associated against an image field:

<asp:Repeater runat="server" DataSource="<%# Actions %>">
    <ItemTemplate>
        <li>
            <sc:Image Field="Image"  runat="server" Item="<%# Container.DataItem as Sitecore.Data.Items.Item %>" />

Now I don't think sitecore by default is meant to put absolute urls in but rather than getting:

<img src="/~/media/image.ashx" />

I'm getting:

<img src="http://<domain>/~/media/image.ashx" />

I need the relative path rather than absolute because the domain can switch between http and https depending on the type of page and the images coming through remain on the http side no matter what.

Is there a way I can alter the sc:Image MediaUrlOptions perhaps?

Thanks

Upvotes: 0

Views: 1390

Answers (1)

ToddB
ToddB

Reputation: 1474

See what this value in your web.config is set to. <setting name="Media.AlwaysIncludeServerUrl" value="false" />

You need it to be false or blank.

Upvotes: 5

Related Questions