I modified the code to make the image and link quicktags more user friendly.
This is for quicktags 4.7, but can be easily modified to work with 4.6. Add this to the list of quicktag buttons
'ed_link' => array(
'name' => 'link',
'suffix' => '</a>',
'accesskey' => 'a',
'close' => FALSE,
'location' => 'edInsertLink',
'icon' => $path .'ed_link.png',
),
'ed_image' => array(
'name' => 'image',
'accesskey' => 'i',
'close' => FALSE,
'location' => 'edInsertImage',
'icon' => $path .'ed_image.png',
),
then put this code at the end of quicktags.module
function edInsertLink(myField, i, defaultValue) {
if (!defaultValue) {
defaultValue = 'http://';
}
if (!edCheckOpenTags(i)) {
var URL = prompt('Enter the URL' ,defaultValue);
if (URL) {
edButtons[i].tagStart = '<a href="' + URL + '">';
edInsertTag(myField, i);
}
}
else {
edInsertTag(myField, i);
}
}
function edInsertImage(myField, i, defaultValue) {
if (!defaultValue) {
defaultValue = '';
}
if (!edCheckOpenTags(i)) {
var URL = prompt('Enter the URL' ,defaultValue);
if (URL) {
edButtons[i].tagStart = '<img class="r" src="' + URL + '">';
edInsertTag(myField, i);
}
}
else {
edInsertTag(myField, i);
}
}
Now when you click Image or Link, a pop up window asks for the url.
Comments
Comment #1
justin3 commentedin the above code, about 5 lines from the bottom, change {image class="r"} to {image align="right"}, or add a .r spec to your .css file, or just delete class="r"
... and i should have specified that the two functions should be placed at the end of the quicktags.module - just before "EOD;"
Comment #2
justin3 commentedjust changing the title back
Comment #3
Bèr Kessels commentedI am very interested in this! I've had this on my todolist for a while now.
A question to you, though. Do you know how to make a patch? It makes reviewing and testing a lot easier. If you want to learn how to do patching and diffing, refer to http://drupal.org/diffandpatch. If that is still not clear, don't hesitate to contact me in private, so that I can hold your hands on the first steps in DrupalPatchingLand :)
Bèr
Comment #4
justin3 commentedNo- sorry, I have no idea how to make a patch.... I'm a hacker, as in I goof around with strange code that I don't really understand, hoping eventually i can make something work.
i surprised myself when i got this code to work... please feel free to make a patch with this (o ;
on another note re: quicktags module, i still haven't found out how to make the keyboard shortcuts work... any clues? ie it says accesskey b=bold, but i try ctrl-b, alt-b etc to no avail. (using linux 2.6.15, firefox 1.5)