I'm trying to create a plugin in which I can use a video lightbox. The user has to enter a youtube link, hit submit and then I enter the data into the editor.
For text and when having nothing selected, it all works fine. When however I select an image that I added to the editor using the "images" button, I cannot seem to get the correct data e.g. <img src="img.jpg">. I always get an empty string. What is the correct code to get what I want?
This is my onOk function:
Thanks in advance
For text and when having nothing selected, it all works fine. When however I select an image that I added to the editor using the "images" button, I cannot seem to get the correct data e.g. <img src="img.jpg">. I always get an empty string. What is the correct code to get what I want?
This is my onOk function:
onOk: function () {
var selectedText = "";
for (var i = 0; i < window.frames.length; i++) {
if (window.frames[i].name == 'iframeYoutubeEmbed') {
var content = window.frames[i].document.getElementById("embed").value;
}
}
var mySelection = editor.getSelection();
if (CKEDITOR.env.ie) {
mySelection.unlock(true);
selectedText = mySelection.getNative().createRange().text;
} else {
selectedText = mySelection.getNative();
}
if (selectedText == "") { selectedText = content; }
final_html = '<p><a rel="#voverlay" href="' + content + '" class="Youtube_embed">' + selectedText + '</a></p>';
editor.insertHtml(final_html);
}
Thanks in advance
