I am trying to retrieve the html markup of the content selected by the user in the CKEditor 3.6.5.

It works fine when the content is some text.

But it does not retrieve it if the content is an image.

This is needed to then wrap a link around the image.

Here is the code that works for the text content:

var getSelectedText = function(editor) {
var selectedText = '';
var selection = editor.getSelection();
console.log("The selected element: " + selection.getSelectedElement());
if (selection.getType() == CKEDITOR.SELECTION_TEXT) {
if (CKEDITOR.env.ie) {
selectedText = selection.getNative().createRange().text;
} else {
selectedText = selection.getNative();
console.log("Ths is not IE");
console.log("The type is CKEDITOR.SELECTION_TEXT");
console.log("The selected text: " + selectedText);

I'm trying to see how to have it also retrieve image content.

To log in:

To see it in action:

Kind Regards,