Ticket #884 (closed enhancement: wontfix)
More possibilities in InsertImage - Code included
| Reported by: | henrik.andersen@… | Owned by: | gogo |
|---|---|---|---|
| Priority: | normal | Milestone: | Version 1.0 |
| Component: | Xinha Core | Version: | |
| Severity: | normal | Keywords: | |
| Cc: |
Description
Added more possibilities to insertimage function, so that users can make their own insertimage plugin with more functionality and don't have to change htmlarea.js ... and more functionality can be added to the insertimage plugin in the future.
Added class, height, width and title
NEW CODE FOR HTMLAREA.JS:
// Called when the user clicks on "InsertImage?" button. If an image is already // there, it will just modify it's properties. HTMLArea.prototype._insertImage = function(image) {
var editor = this; // for nested functions var outparam = null; if ( typeof image == "undefined" ) {
image = this.getParentElement(); if ( image && image.tagName.toLowerCase() != 'img' ) {
image = null;
}
} if ( image ) {
outparam = {
f_base : editor.config.baseHref, 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_class : image.className,
f_height : image.height, f_width : image.width, f_title : image.title
};
} this._popupDialog(
editor.config.URIs.insert_image, function(param) {
// user must have pressed Cancel if ( !param ) {
return false;
} var img = image; if ( !img ) {
if ( HTMLArea.is_ie ) {
var sel = editor._getSelection(); var range = editor._createRange(sel); editor._doc.execCommand("insertimage", false, param.f_url); img = range.parentElement(); // wonder if this works... if ( img.tagName.toLowerCase() != "img" ) {
img = img.previousSibling;
}
} else {
img = document.createElement('img'); img.src = param.f_url; editor.insertNodeAtSelection(img); if ( !img.tagName ) {
// if the cursor is at the beginning of the document img = range.startContainer.firstChild;
}
}
} else {
img.src = param.f_url;
}
for ( var field in param ) {
var value = param[field]; switch (field) {
case "f_alt":
img.alt = value;
break; case "f_border":
img.border = parseInt(value
"0", 10); break; case "f_align":
img.align = value;
break; case "f_vert":
img.vspace = parseInt(value
"0", 10); break; case "f_horiz":
img.hspace = parseInt(value
"0", 10); break; case "f_class":
img.className = value;
break; case "f_height":
img.height = value;
break; case "f_width":
img.width = value;
break; case "f_title":
img.title = value;
break;
}
}
}, outparam);
};
Attachments
Change History
Note: See TracTickets for help on using tickets.Download in other formats:
