The easiest way to demonstrate the problem is to use the demo at http://ckeditor.com/demo:
1) Open the image dialog and set the URL to /apps/ckeditor/3.2/skins/kama/images/noimage.png
2) Click "OK" to insert the image
3) Select the image and cut or copy it
4) Paste the image from the clipboard (anywhere within the document)
5) The image should still display fine in the document, but ...
6) Right click the image and choose "Image Properties" to launch the image dialog
7) The URL becomes apps/ckeditor/3.2/skins/kama/images/noimage.png -- missing the beginning "/"
It seems that when an image is cut/copy and paste, CKEditor resolves a relative URL by referencing the editor's current location. I tried setting the config file's baseHref to "/", but it doesn't help. I need to keep the URL in the relative from the root format.
Fri, 03/05/2010 - 16:51
#1
Re: Cutting/Coping and Pasting of an image change its src
I have the same problem. Is there any solution to this?
Copying and pasting content from withing same website breaks links because it is converting absolute to relative
Re: Cutting/Coping and Pasting of an image change its src
BTW, for those who have the same problem, I "fixed" it using php later on. We should check user input anyway so it shouldn't be a problem adding one more line to check script:
$text = preg_replace ('/\<a\ href\=\"..\/([.\/]*?)([^.^\/])/i', '<a href="' .$site_domain .'$2', $text);
I'm assuming your editor text is stored in $text and $site_url is your site domain, like http://www.somewhere.com [do _NOT_ forget http].
What is does is it replaces all ../ in link from <a href="../../ (...) ../somewhere/file with <a href="http://www.somewhere.com/somewhere/file