Stop Umbraco/tinymce From Converting Absolute Urls To Relative Urls
Both Umbraco/TinyMce both like to strip the base domain from any absolute URLs in the editor. This is problematic as I have an RSS feed that scrapes my posts, and emails them weekl
Solution 1:
An alternative is to use a parser, regex, or substring methods. I also don't have to worry about maintaining any changes I would have made to the Umbraco framework.
I ended just using a simple substring at the very moment I'm calling this information for the RSS feed:
var bt = node.GetProperty("bodyText").Value
.Replace("src=\"/","src=\"https://example.com/")
.Replace("href=\"/","href=\"https://example.com/");
@Html.Raw(bt);
Any src and href attributes with a forward slash as the first character will get replaced with the base domain name. This works perfectly for my setup, but might cause issues if you were displaying code in a blog post, for example.
A parser such as HTML Agility Pack pack is better, but I don't need it if I can solve my issue with technically 1 new line of code.
Post a Comment for "Stop Umbraco/tinymce From Converting Absolute Urls To Relative Urls"