01 Aug 2014
21 Sep 2015
Link to this post
I have a custom widget that shows a collection of images in a slideshow. Each image is a property of a Dynamic Content Type object returning a Telerik.Sitefinity.Libraries.Model.Image object, from which I get the MediaUrl property. This property returns a value like "http://localhost:60876/images/default-source/Heros/slide1.jpg?sfvrsn=2".
The problem is that the URL is fully specified, includeing the protocol, instead of a root relative URL (e.g. /images/default-source/Heros/slide1.jpg?sfvrsn=2).
Our production servers are load balanced by an F5 device, which also hosts the SSL certificate, so the actual servers don't know that the site is using HTTPS instead of HTTP. This means the image's MediaUrl property returns a value like "http://www.mysite.com/images/default-source/Heros/slide1.jpg?sfvrsn=2". But this is the wrong URL (http instead of https) so the browser shows an insecure connection to the server because of the mixed content.
I could use the image's ItemDefaultUrl property, which is root relative but doesn't include the cache busting sfvrsn query string property (ex /images/default-source/Heros/slide1).
Is there a way to get an image's root relative Url with the sfvrsn query string parameter?