Senior Director &National Competency Lead – Sitecore Commerce
Multisite Solution Preview Mode with Images
In one of my previous blog posts, I mentioned how to [Preview an Item in workflow for a Multisite Solution](http://www.xcentium.com/blog/2016/08/05/preview-an-item-in-workflow "Preview an Item in workflow for a Multisite Solution"). However, the content authors at one of our clients reported that the preview mode was not displaying any images when they are using the Preview Mode every once in a while. The images only show up when they are published to the web database. This article outlines the steps I have taken in order to troubleshoot the issue.
We use Sitecore.Resources.Media.MediaManager.GetMediaUrl() for generating the URL's for the media items.
Let's consider we have two websites, myFirstSite and mySecondSite with host names as myfirstsite.com and mysecondsite.com respectively.
The content author is logged into sitecore using http://myfirstsite.com/sitecore and working on creating a web page for the other site. When they start the preview mode in the Experience Editor, it displays all the content except Media Items.
If you use developer tools and inspect the image URL for the media items, it looks as http://myfirstsite.com/sitecore/shell/-/media/... It resolves the image fine if we manually change to http://mysecondsite.com/sitecoe/shell/-/media...
Why it happens?
Sitecore has a setting Media.AlwaysIncludeServerUrl which determines whether the Media Item should always show the server URL or not. By default, it is set to use the same value defined in the link provider.
Have to look into more details to find out what's the underlying issue by checking the following processors.
<getpagepreviewurl> <processor type="Sitecore.Pipelines.GetPagePreviewUrl.GetDefaultUrlOptions, Sitecore.Kernel"></processor> <processor type="Sitecore.Pipelines.GetPagePreviewUrl.SetLanguage, Sitecore.Kernel"></processor> <processor type="Sitecore.Pipelines.GetPagePreviewUrl.GetUrl, Sitecore.Kernel"></processor> </getpagepreviewurl>
Until we find a permanent solution, I took the following temporary work-around approaches