2
votes

We have a Sitecore 6.6 updated from 6.3.

On 6.3 when an image was linked from the media library in the rich text editor, the src generated link looked like this:

src="/~/media/499880737CD24BF7A640E0DB2652C909.ashx?w=646&h=830&as=1"

Which worked fine.

Now after the update to 6.6 a leading slash is added to the src:

src="//~/media/499880737CD24BF7A640E0DB2652C909.ashx?w=646&h=830&as=1"

The image is visible in the rich text editor in the backend, but not on the website.

So where does this leading slash come from? I googled and tried many possible solutions, but nothing worked so far. I also checked this thread (Sitecore 6.5 rev. 120247 media urls adding a leading slash), but my "Media.MediaLinkPrefix" is already empty.

EDIT:

I just checked our 6.3 backup and the image src actually looks like this:

src="//hostname/~/media/499880737CD24BF7A640E0DB2652C909.ashx?w=646&h=830&as=1"

Could the missing hostname be the problem? If I add manually add it and put it into the browser, it works.

2
I don't know how new your install is, or when you plan on upgrading, but I would consider it. 6.6 is quite old. Consider overloading the LinkManager and/or decompiling Sitecore.Kernel.dll to see where it might be happening. I know the latter is not a small task, but potentially worth a look.Zachary Dow
Anything odd in the "Media."-related settings in your web.config? Media.MediaLinkPrefix?Jim Noellsch
Have you checked you don't have a patch include file setting the Media.MediaLinkPrefix settin elsewhere (check via /sitecore/admin/showconfig.aspx)? The example you have given is from the RTE raw values right? It seems you have either this setting somewhere in your configs or a custom implementation like Media URL Transformer in use.jammykam
I checked the /sitecore/admin/showconfig.aspx page and Media.MediaLinkPrefix is set to "" and <handler trigger="~/media/" handler="sitecore_media.ashx" />, which should be fine, right?SpaceJump
Those are the correct settings, so a bit strange. Just to be doubly sure, make sure there are not 2 occurances of Media.MediaLinkPrefix in showconfig (it's just the way the patching works). Otherwise I would be tempted to raise a support ticket with Sitecore since they can get more access to your environment in order to help debug.jammykam

2 Answers

3
votes

I think this might be due to a change in the way media items urls are rendered in Sitecore 6.4+.

According to Sitecore John, in versions 6.4 and above, a slash is prepended to the media url to solve some issues with SEO and IIS. If you already have code such as this:

 mediaPath = Sitecore.StringUtil.EnsurePrefix('/',MediaManager.GetMediaUrl(mediaItem))

You will now have two slashes rather than just one.

More info on this here:

http://www.sitecore.net/learn/blogs/technical-blogs/john-west-sitecore-blog/posts/2012/12/sitecore-idiosyncrasies-media-urls.aspx

0
votes

To fix that, check the following settings involved in src generation and processing:

    <customHandlers>
        ...
        <handler trigger="~/media/" handler="sitecore_media.ashx" />
        ...
    </customHandlers>

If it starts with slash - remove it. Also check that setting, that assigns a prefix to media links:

<setting name="Media.MediaLinkPrefix" value="" />

Finally, there can be any URL Rewrite feature (or reverse proxy) enabled that rewrites URL on the fly, however that is very unlikely.