Skip to main content
Topic: [ADDON/TRICK] favicon next to links (Read 2785 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[ADDON/TRICK] favicon next to links

That's really just a small trick, add this code... somewhere, for example in Load.php, close to:
Code: [Select]
call_integration_hook('integrate_load_theme');
Yes, I'm just being lazy, I don't want to write the package for it. :P
I created the package and uploaded as usual at github, scroll down for details.

Code: [Select]
	addInlineJavascript('
$(document).ready(function() {
$(\'.bbc_link\').each(function() {
var url = $(this).attr(\'href\'),
domain = url.match(/:\/\/(.[^/]+)/)[1],
schema = url.match(/^(http[s]*):\/\//)[1];
$(this).css({
\'background-image\': \'url(//www.google.com/s2/favicons?domain=\' + schema + \'://\' + domain + \')\',
\'background-repeat\': \'no-repeat\',
\'padding-left\': \'20px\'
});
});
})', true);

This will show the favicon of the site you linked in posts.
So, using for example:
Code: [Select]
[url=http://www.elkarte.net/community/index.php]ElkArte[/url]
It will show:
ElkArte

License
o This ElkArte Addon is subject to the terms of the BSD "3-clause" license. You can obtain a copy of the License at http://opensource.org/licenses/BSD-3-Clause

Repository / Download



Change log

  • 0.0.1 - Initial release
Bugs creator.
Features destroyer.
Template killer.

Re: [ADDON/TRICK] favicon next to links

Reply #1
Nice tip/addon. May be the favicon can be better aligned and add some space as between them.

Re: [ADDON/TRICK] favicon next to links

Reply #2
Do not trust what you see above in the "It will show:" in terms of spacing alignment, this is standard bbcode, while the way the addon appears is different (I was too lazy to take a real screenshot LOL).
Bugs creator.
Features destroyer.
Template killer.

Re: [ADDON/TRICK] favicon next to links

Reply #3
I will have a try later. It's sure a nice mod to have anyway.

Re: [ADDON/TRICK] favicon next to links

Reply #4
Download link not working @emanuele


Re: [ADDON/TRICK] favicon next to links

Reply #6
Can we use YQL instead? How to translate this code (using http://bbc.co.uk/ as domain):

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D"http://bbc.co.uk/"and%20xpath%3D"/html/head/link[@rel%3D'icon']%20|%20/html/head/link[@rel%3D'ICON']%20|%20/html/head/link[@rel%3D'shortcut%20icon']%20|%20/html/head/link[@rel%3D'SHORTCUT%20ICON']"&format=json&callback=grab

Re: [ADDON/TRICK] favicon next to links

Reply #7
Thank you very much @Spuds

Re: [ADDON/TRICK] favicon next to links

Reply #8
I'm also using it on my test forum, I like this simple addon ;)
sorry for my bad english

Re: [ADDON/TRICK] favicon next to links

Reply #9
Can we use YQL instead? How to translate this code (using http://bbc.co.uk/ as domain):

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D"http://bbc.co.uk/"and%20xpath%3D"/html/head/link[@rel%3D'icon']%20|%20/html/head/link[@rel%3D'ICON']%20|%20/html/head/link[@rel%3D'shortcut%20icon']%20|%20/html/head/link[@rel%3D'SHORTCUT%20ICON']"&format=json&callback=grab

I guess its possible. But it may require some more "tricks".
I suspect you are referring to:
http://stackoverflow.com/questions/2057636/get-websites-favicon-with-js
These urls return either a json object (in case as argument of a function) or an xml file. So, instead of apply the google url to the background property, it means: do the "query", grab the favicon from the result, and set it.
Bugs creator.
Features destroyer.
Template killer.

Re: [ADDON/TRICK] favicon next to links

Reply #10
I agree it's simple but makes links look so much better.

Re: [ADDON/TRICK] favicon next to links

Reply #11
Is there a way to disable this addon into signatures? I have no links enabled into sigs but with this addon the links are visible into signature
sorry for my bad english

Re: [ADDON/TRICK] favicon next to links

Reply #12
That's unlikely, this addon just adds a bit of javascript, if something is not there it cannot be shown... :-\
Van you point me to a page where I can see it "in action"?
Bugs creator.
Features destroyer.
Template killer.

Re: [ADDON/TRICK] favicon next to links

Reply #13
I should first try on a clean install to see if a member can add links into signature if the url and iurl codes are disabled for signatures. you can see it here skodaclub.it/index.php?topic=5802
the author of the post has a link into his signature. It's not a big problem for me, I can live with this, but I was just curious to know if this is caused by the addon
sorry for my bad english

Re: [ADDON/TRICK] favicon next to links

Reply #14
Is there a way to disable this addon into signatures? I have no links enabled into sigs but with this addon the links are visible into signature
replace

Code: [Select]
		$(\'.bbc_link\').each(function() {

with

Code: [Select]
		$(\'.inner .bbc_link\').each(function() {

untested!