Wordpress flickr link quicktag

KarmaDude Sep 15, 2006 3 Comments

flickr quicktag
Here is the code to add a handy flickr link quicktag to your Wordpress post editor.

Sample:
This is what a link generated by the flickr quicktag to my flickr page looks like: flickr: Karmadude on flickr

Code:digg this
Step 1: Use the code below to add a new Flickr link button to the quicktags.js file. You can find this file in the wp-includes/js folder in your WordPress installation.

edButtons[edButtons.length] =
new edButton('ed_flickr‘
,’flickr’
,”
,’‘
,’f’
); // special case

Step 2: Next add a click event handler for the newly created flickr button. Find the edShowButton function in your quicktags.js file. This function defines the click event handler function to call, when a quicktag button is clicked. Add the following code before the last else.

else if (button.id == 'ed_flickr‘) {
       document.write(’<input type=”button” id=”‘ + button.id + ‘” accesskey=”‘ + button.access + ‘” class=”ed_button” onclick=”edInsertFlickr(edCanvas, ‘ + i + ‘);” value=”‘ + button.display + ‘” />’);
   }

Step 3: Finally, create edInsertFlickr, the click event handler function. This function will add the styled flickr tag before the link.

function edInsertFlickr(myField, i, defaultValue) {
   if (!defaultValue) {
    defaultValue = ‘http://’;
   }
   if (!edCheckOpenTags(i)) {
    var URL = prompt(’Enter the Flickr URL’ ,defaultValue);
    if (URL) {
        edButtons[i].tagStart = ‘<strong style=”color:#3993ff”>flick<span style=”color:#ff1c92″>r</span></strong>: <a href=”‘ + URL + ‘”>’;
        edInsertTag(myField, i);
    }
   }
   else {
    edInsertTag(myField, i);
   }
}


Finally:

Login to your Wordpress admin area, bring up the post editor, and test if the new flickr quicktag works. If you don’t see the flickr quicktag button, refresh your browser. That’s all there is to it.

Related Posts:
Wordpress: Custom quicktags

3 Comments

  • pierro
    Sep 15, 2006 | 5:23 pm

    hey; thats nice ! thumbs up . . . but; I has not a own Wordpress_space but instead a free host :
    pierro.blogsport.de

    im not a big computer_nose: thats why my question ; can i still use this code_snip ?

  • KarmaDude
    Sep 15, 2006 | 5:33 pm

    Pierro, if you can access and edit the files on your host server, you should be able to add the code to your quicktags.js file. Hope that helps.

  • pierro
    Sep 16, 2006 | 8:54 pm

    tank you for you`r feedback . I think i has, looks very much like code_snips in my wordpress_account :-)
    i will start a test, and than, i will see.
    have meet a nice day . . .

Leave a Comment

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>