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='.jpg' />
The initialization I tried is as follows:
<script type="text/javascript">
$(document).ready(function() {
$('#editor1').ckeditor({ baseHref: "/" });
});
</script>
but didn't work.
On some posts I found using baseUrl
and baseDir
could solve the issue. I tried this:
$('#editor1').ckeditor({
baseHref: "/",
baseUrl: "/",
baseDir: "/newsletter/"
});
but that didn't work either.
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./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./" });
});
</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./",
baseUrl: "http://www.mydomain./newsletter/",
baseDir: "/newsletter/"
});
but that didn't work either.
Share Improve this question edited Aug 22, 2012 at 10:48 spolto 4,5514 gold badges28 silver badges34 bronze badges asked Jan 25, 2012 at 3:54 PrajwalPrajwal 2981 gold badge7 silver badges19 bronze badges3 Answers
Reset to default 4I 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
As per the ckeditor documentation this is how it is set:
{String} CKEDITOR.config.baseHref Since: 3.0 The base href URL used to resolve relative and absolute URLs in the editor content. config.baseHref = 'http://www.example./path/'; Default Value: '' (empty string)
http://docs.cksource./ckeditor_api/symbols/CKEDITOR.config.html
baseUrl is the setting that you're searching for, but it's a CKFinder setting that you must set in your server. It can't be set on javascript, and of course not on a CKEditor instance.