Changing the site favicon
From Joomla! Documentation
(Difference between revisions)
m (changed the directory name to include "your_template" and added the backup/security hints.) |
|||
| Line 22: | Line 22: | ||
From the html.php | From the html.php | ||
| − | + | <source lang="php"> | |
| − | + | // Try to find a favicon by checking the template and root folder | |
| − | + | $path = $directory . DS; | |
| − | + | $dirs = array( $path, JPATH_BASE . DS ); | |
| − | + | foreach ($dirs as $dir ) | |
| − | + | { | |
| − | + | $icon = $dir . 'favicon.ico'; | |
| − | + | if (file_exists( $icon )) | |
| − | + | { | |
| − | + | $path = str_replace( JPATH_BASE . DS, '', $dir ); | |
| − | + | $path = str_replace( '\\', '/', $path ); | |
| − | + | $this->addFavicon( JURI::base(true).'/'.$path . 'favicon.ico' ); | |
| − | + | break;'' | |
| − | + | </source> | |
Revision as of 01:26, 3 September 2009
- Create a 16x16 pixel image. You may use graphic software such as Photoshop, Gimp or Windows Paint or an online tool such as http://antifavicon.com/
- Convert to ico format using free online sites such as:
- The file you created in this way will have the extension .ico. Copy the file to the /joomla/templates/<your template> directory and name it favicon.ico.
- Open a browser. Do you see your new icon? If so, congratulations. If not, that doesn't necessarily mean you did anything wrong. Browsers are designed to minimize data traffic, so they don't refresh the favicon every time they show a page. Even refreshing the page (F5) wont help. So you need to refresh more thoroughly:
- Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac);
- IE: hold Ctrl while clicking Refresh, or press Ctrl-F5;
- Konqueror: simply click the Reload button, or press F5;
- Opera users may need to completely clear their cache in Tools→Preferences.
If this doesn't work you will need to delete the temporary internet files and the history and then open your page again.
<link rel="shortcut icon" href="http://yoursite.com/templates/your_template/icon/favicon.ico" />If you don't want to just change the favicon.ico file in its respective template directory you can find the reference to the favicon.ico file in the html.php document. The path is "........\libraries\joomla\document\html\html.php". This should prevent the icon from toggling if you use
<link rel="shortcut icon" href="http://yoursite.com/templates/your_template/icon/youricon.ico" />in the template html and you don't remove the favicon.ico file. (why call the icon twice?)
From the html.php
// Try to find a favicon by checking the template and root folder $path = $directory . DS; $dirs = array( $path, JPATH_BASE . DS ); foreach ($dirs as $dir ) { $icon = $dir . 'favicon.ico'; if (file_exists( $icon )) { $path = str_replace( JPATH_BASE . DS, '', $dir ); $path = str_replace( '\\', '/', $path ); $this->addFavicon( JURI::base(true).'/'.$path . 'favicon.ico' ); break;''