diff --git a/urlicon.module b/urlicon.module
index 44f9e97..c13705c 100644
--- a/urlicon.module
+++ b/urlicon.module
@@ -140,6 +140,19 @@ function _urlicon_format_favicon($match) {
   $url = @parse_url($match[1]);
   $domain = explode('.', $url['host']);
   $domain = check_url(str_replace('.', '_', $url['host']));
+  
+  // Get link attributes
+  $link_attributes = array();
+  try{
+    $xml = (array) simplexml_load_string($match[0]);
+    $attrs = (array) $xml['@attributes'];
+    if(isset($attrs['href'])) {
+      unset($attrs['href']);
+    }
+    $link_attributes = $attrs;
+  }catch(Exception $e) {
+    watchdog('urlicon', "Error @error", array('@error' => $e->getMessage()));
+  }
 
   //check if favicon exists locally
   if ($url['host'] AND !file_exists($dir .'/'. $domain .'.ico')) {
@@ -199,7 +212,7 @@ function _urlicon_format_favicon($match) {
   // check for favicon availability
   $favicon = file_exists($dir .'/'. $domain .'.ico') ? (file_create_url($dir .'/'. $domain .'.ico')) : (base_path().drupal_get_path('module', 'urlicon') .'/Icon_External_Link.png');
   
-  $link = theme('urlicon', $match[3], $favicon, $match[1], array('alt' => '', 'title' => t('favicon'), 'class' => 'urlicon urlicon-'. check_plain($domain)));
+  $link = theme('urlicon', $match[3], $favicon, $match[1], array('alt' => '', 'title' => t('favicon'), 'class' => 'urlicon urlicon-'. check_plain($domain)), $link_attributes);
   return $link;
 }
 
@@ -264,7 +277,8 @@ function urlicon_theme($existing, $type, $theme, $path) {
         'text' => NULL,
         'favicon' => NULL,
         'path' => NULL,
-        'attributes' => array(),
+        'img_attributes' => array(),
+        'link_attributes' => array(),
       ),
     ),
   );
@@ -273,7 +287,7 @@ function urlicon_theme($existing, $type, $theme, $path) {
 /**
  * Return a themed link with a favicon.
  */
-function theme_urlicon($text, $favicon, $path, $attributes = array()) {
-  $favicon = '<img src="'. $favicon .'" '. drupal_attributes($attributes) .' />';
-  return l($text .' '. $favicon, $path, array('absolute' => TRUE, 'html' => TRUE));
+function theme_urlicon($text, $favicon, $path, $img_attributes = array(), $link_attributes = array()) {
+  $favicon = '<img src="'. $favicon .'" '. drupal_attributes($img_attributes) .' />';
+  return l($text .' '. $favicon, $path, array('attributes' => $link_attributes, 'absolute' => TRUE, 'html' => TRUE));
 }
\ No newline at end of file

