A directory of browser-based WYSIWYG editors


Home: htmlArea 3 (beta): htmlArea 2 & 3 archive (read only): htmlArea v3.0 - Add-Ons:
How to get current seleted image data into plugin

The htmlArea 2 & 3 editors have been discontinued.

We've made these forums available as a read-only reference and knowledge-base for people using or developing editors based on htmlArea 2 or 3.

Anyone who is interested in taking over version 2 or 3 is free to do so. All we ask is that you choose a new name that doesn't have "htmlarea" in it to avoid confusion with this site. We'll even give you a link in the directory to make it easier for people to find you. If you are developing or hosting an htmlArea based-editor under a new name, please submit it to our directory.


New User

Oct 6, 2004, 2:26 PM

Post #1 of 3 (5077 views)
How to get current seleted image data into plugin Can't Post

Hello, I've been working on creating a plugin that does two things. First it overwrites the base insert image function with a custom PHP version that just lets you select an image you want to insert. It also creates a second button that is for the image properties. Where I'm having problems is in getting the currently selected image data to be passed to the plugin function. Here is the function I have now:


ImageGallery.prototype.buttonPress = function(editor, id) {
switch (id) {
case "IG-image-property":
ImageGallery.editor = editor;
ImageGallery.init = true;
var uiurl = _plugin_url + "plugins/ImageGallery/image_property.html";
var outparam = null;

//var image = editor._iframe.contentWindow.getSelection();
//var image = editor.getSelectedHTML()

if (typeof image == "undefined") {
image = editor.getParentElement();
if (image && !/^img$/i.test(image.tagName))
image = null;

if (image) outparam = {
f_url : HTMLArea.is_ie ? editor.stripBaseURL(image.src) : image.getAttribute("src"),
f_alt : image.alt,
f_border : image.border,
f_align : image.align,
f_vert : image.vspace,
f_horiz : image.hspace,
f_width : image.width,
f_height : image.height

Dialog(uiurl, function(param) {
if (!param) { // user must have pressed Cancel
return false;
var img = image;
if (!img) {
var sel = ImageGallery.editor._getSelection();
var range = ImageGallery.editor._createRange(sel);
ImageGallery.editor._doc.execCommand("insertimage", false, param.f_url);
if (HTMLArea.is_ie) {
img = range.parentElement();
// wonder if this works...
if (img.tagName.toLowerCase() != "img") {
img = img.previousSibling;
} else {
img = range.startContainer.previousSibling;
} else {
img.src = param.f_url;

for (field in param) {
var value = param[field];
switch (field) {
case "f_alt" : img.alt = value; break;
case "f_border" : img.border = parseInt(value || "0"); break;
case "f_align" : img.align = value; break;
case "f_vert" : img.vspace = parseInt(value || "0"); break;
case "f_horiz" : img.hspace = parseInt(value || "0"); break;
case "f_width" : img.width = parseInt(value || "0"); break;
case "f_height" : img.height = parseInt(value || "0"); break;

}, outparam);


Oct 6, 2004, 5:47 PM

Post #2 of 3 (5075 views)
Re: [gcw07] How to get current seleted image data into plugin [In reply to] Can't Post

Um... doesn't the current Image popup do both those things?

If not, there's always - the Image Manager.

New User

Oct 7, 2004, 12:50 PM

Post #3 of 3 (5054 views)
Re: [kimastergeorge] How to get current seleted image data into plugin [In reply to] Can't Post

Sorry I wasn't specific enough. I'm overwriting the current insert image function with an image gallery that is built directly into the script. Which means all you do is select an image name instead of typing in a full url like the default one. While the Image Manager is fine it doesn't quite do what I want. It is overwriting the base insert image just like I am but it isn't splitting off the properties. I'm doing this because I don't want users to have to wait on loading up the gallery again just to edit the properties, which is why I'm trying to figure out how to get the currently selected item passed back into that function. Thanks.


Search for (options)