How to add favicons to external links
Here I will show you, how I added favicons to external links. This solution will use JS and it will use a google-API to fetch the icon.
I have searched for a long time for this, and this morning I found a quite simple solution.
The result will look like this:
To get this, just do this:
create dokuwiki/conf/userscript.js and paste this:
/* add icons to external links via google-service */
setTimeout((function (){
jQuery("a.urlextern ").each( function (nId,oData,oError){
jQuery(oData).css(
"background-image",
"url(\"https://www.google.com/s2/favicons?domain="+jQuery(oData).prop("hostname")+"\")");
});
}));
Note: setTimeout will make sure, that the function is placed last on the event loop, so (hopefully) this is applied after all other script ran.
edit: Thanks for the feedback, everyone. I updated the post accordingly.
Next I will try to implement the google-service myself, because I don't want google to know all my users IP-adresses and all domains linked on my wiki. If there is a general interest in this, I will also try to make this become a plugin.
ps: this is my first real post here. please be gentle~