I am using CKEDITOR for creating newsletters. Everything went fine but when I send newsletters to email, the images stored there aren't displayed. The problem was caused by CKEDITOR using relative path for image sources, e.g. <img src='/newsletter_images/news1/img1.jpg'>
.
I want CKEDITOR to use absolute urls such as:
<img src='http://www.mydomain.com/newsletter_images/news1/img1.jpg' />
The initialization I tried is as follows:
<script type="text/javascript">
$(document).ready(function() {
$('#editor1').ckeditor({ baseHref: "http://www.google.com/" });
});
</script>
but didn't work.
On some posts I found using baseUrl
and baseDir
could solve the issue. I tried this:
$('#editor1').ckeditor({
baseHref: "http://www.mydomain.com/",
baseUrl: "http://www.mydomain.com/newsletter/",
baseDir: "/newsletter/"
});
but that didn't work either.
I believe the problem has to do with the idea that the ckeditor is mainly for webpage-based use. When you are sending all this in an email, I would think the ckeditor no longer keeps track of that baseHref for you.
If you found a way to add on that baseHref to each link before the email is sent out (using whatever server-side language you might be using,) it might end up with the result that you want.
Something like this (pseudocode):
// get ckeditor text
// find/replace <a href=""></a> links with baseHref + link
// mail result
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With