MediaUrl vs ItemDefaultUrl
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 "localhost:60876/.../slide1.jpg
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 "www.mysite.com/.../slide1.jpg. 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?
Thanks
Dan
Hi Dan,
I have just replied in the ticket you have opened related to this. Here is my reply for your convenience:
Please try to use the ResolveMediaUrl() in order to retrieve the relative url of the image:
string
relativeUrl = image.ResolveMediaUrl();