Quantcast
Channel: C1 CMS Foundation - Open Source on .NET
Viewing all articles
Browse latest Browse all 2540

New Post: Get full path of image in medial location to send newsletter

$
0
0
You can write some code that would iterate "img" elements and appends the server url, something like this:
[FunctionParameter]
XhtmlDocument Content { get; set; }

....


// Code that fixes urls
string serverUrl = new Composite.Core.UrlBuilder(Request.Url.AbsoluteUri).ServerUrl;

var imageTags = Content.Root.Elements().Where(e => e.Name == "img").ToList();

foreach(var img in imageTags) {
 string src = (string) img.Attribute("src");
 
 if(src.StartsWith("/media")) {
    img.Attribute("src").Value = serverUrl + src;
 }
}

// ...
string emailhtml = Content.ToString();

Viewing all articles
Browse latest Browse all 2540

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>