Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Is your source for the image link a LinkCollection property? If you just render it using the property web control, will it display a link to the correct virtual path of the image?
This works in my CMS 6 installation:
string permanentLink = "~/link/9abeeb4114cd4c129187aa2562eaa849.jpg";
UrlBuilder url = new UrlBuilder(permanentLink);
PermanentLinkMapStore.ToMapped(url);
lblTest.Text = url.ToString();
Hello,
Thank you for your response.
The source is not a LinkCollection but a regular URL to Image Property.
I tried using the PermanentLinkMapStore before but I still cannot get the virtual path.
Cheers,
Victor
What if you get the PropertyData and ToString it rather than trying to get it's value? I think this is what the Property control does in this case. Do something like this:
string url;
PropertyData data = page.Property["MyProperty"];
if ((data == null || data.IsNull) { // Fallback here }
url = data.ToString();
In there somewhere it uses a permanent link map, use Reflector if you want to dig further into the details.
Hello there
Does anyone know how to change a Permanent Link such as “~/link/e76463a4b3604b51952312ca0e404bcd.gif” into a virtual link such as “/Global/images/myimage.jpg”?
There’s a tool to do it for Pages but I haven’t found anything for images.
This is what I’ve tried so far but I keep getting the permanent link or nothing at all:
string mappedLink = item.ToMappedLink();
string permanentLink = item.ToPermanentLink();
var url = new UrlBuilder(item.Href);
bool result = PermanentLinkMapStore.ToMapped(url);
string test = result ? url.ToString() : item.Href;
string str;
PermanentLinkMapStore.TryToMapped(uriToImage, out str);
Thanks,
Victor