Get the selected content even if it is an image

Hello,

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) {
selection.unlock(true);
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);
return(selectedText);
}

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

To log in:
http://demo.learnintouch.com/engine/system/admin/login.php?login=demo&password=demo

To see it in action:
http://demo.learnintouch.com/engine/modules/dynpage/edit_content.php?dynpageId=2

Kind Regards,

I think I solved the issue, at least on Chrome and Firefox, with the function:

var getSelectedContent = function(editor) {
var content = editor.getSelection().getStartElement().getOuterHtml();
return(content);
}

It does get the selected image.