Hi all!I have some properties on a page that are 'URL to an image'. They look like this (yes I will correct the missing alt atribute)
<img src="<%= CurrentPage["pp_theIMG"] %>" alt="" />
The problem is that the path to the image is a relative one, like this: /Global/image01.png. The reason for the problem is that they dont show up in hotmail when the page is sent as a newsletter.So, I want to convert them to absolute, like this: http://www.MySite/Global/image01.pngThis takes some code behind I guess, and I'am not totally lost. I have made this method:
public string imgSRC(string sample)
string result = sample.Replace("/Global/", "http://www.MySite/Global/");
In the front end code I tried this:
<%= imgSRC ("/Global/") %>
But that just writes the new path directly to the page. I want to have it in the property pp_theIMG.I would be mighty thankfull If someone could help me with this problem. Iam expected to get this newsletter done. By the way, making newsletters for hotmail is like going back 10 years in html and css.
Any other way of doing this would also be helpful ofcourse. And please, explain well, Iam rather new to this.
Doh. I can just add the domain in the property. It would be more handy to have them all replaced though.
<img src="<%= http://mySiteCurrentPage["pp_theIMG"] %>" alt="" />
The absolute URL to the image depends on site settings in your web.config. I believe that it's better to store relative URL to image as page property and generate absolute URL using UriSupport.AbsoluteUrlBySettings method. when page is rendered/"sent" as newsletter.
Any chance you are using EPiServer Mail to send your newsletter? EPiServer Mail automatically converts the URLs to absolue. In that case, if they don't show up on hotmail it's either because they are blocked or some setting in EPiServer.config or EPiServerMail.config is wrong so the URLs aren't converted correctly.
Thank you guys (really appriciete your help). No Iam using the "Send page as mail" function in Internet Explorer, then it gets sent by Outlook.
My way, decribed above worked and the images display in hotmail. So problem solved for the moment. Another thing is that hotmail strips all css in the header so I have to work with inline. That becomes a big deal with edit boxes where editor content generates p tags.
Dmytro Duk: that sounds interesting and I will look into it when I have more time. Thank you very much.
But anyway, it would be fantastic to know: is there a way to make c# code to find every /Global/ in the front end code and convert it to another string? Is it hard to do?
You could probably do it with a response filter but I wouldn't say that is necessarily simple. I fear it would be regex hell if you want to make sure you don't change any "legitimate" /Global/ strings referring to something else (say the edit text describes such an URL in an example).
On response filters: http://www.4guysfromrolla.com/articles/120308-1.aspx
Ok I look into it. Thanks again.