diff --git a/xmlsitemap.generate.inc b/xmlsitemap.generate.inc
index 07f0cfe..3f7e358 100644
--- a/xmlsitemap.generate.inc
+++ b/xmlsitemap.generate.inc
@@ -247,6 +247,8 @@ function xmlsitemap_generate_chunk(stdClass $sitemap, XMLSitemapWriter $writer,
       // sitemaps.org specification.
       $element['priority'] = number_format($link['priority'], 1);
     }
+    
+    drupal_alter('sitemap_element', $element, $link);
     $writer->writeSitemapElement('url', $element);
   }
 
diff --git a/xmlsitemap.xmlsitemap.inc b/xmlsitemap.xmlsitemap.inc
index c68e4d6..9c5feaf 100644
--- a/xmlsitemap.xmlsitemap.inc
+++ b/xmlsitemap.xmlsitemap.inc
@@ -62,6 +62,7 @@ class XMLSitemapWriter extends XMLWriter {
    */
   public function getRootAttributes() {
     $attributes['xmlns'] = 'http://www.sitemaps.org/schemas/sitemap/0.9';
+    $attributes['xmlns:image'] = 'http://www.google.com/schemas/sitemap-image/1.1';
     if (variable_get('xmlsitemap_developer_mode', 0)) {
       $attributes['xmlns:xsi'] = 'http://www.w3.org/2001/XMLSchema-instance';
       $attributes['xsi:schemaLocation'] = 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd';
@@ -114,11 +115,17 @@ class XMLSitemapWriter extends XMLWriter {
    */
   public function writeElement($name, $content = '') {
     if (is_array($content)) {
-      $this->startElement($name);
+      if (! is_numeric($name)) {
+        $this->startElement($name);
+      }
+      
       foreach ($content as $sub_name => $sub_content) {
         $this->writeElement($sub_name, $sub_content);
       }
-      $this->endElement();
+      
+      if (! is_numeric($name)) {
+        $this->endElement();
+      }
     }
     else {
       parent::writeElement($name, $content);
diff --git a/xmlsitemap_image/xmlsitemap_image.info b/xmlsitemap_image/xmlsitemap_image.info
new file mode 100644
index 0000000..86c0720
--- /dev/null
+++ b/xmlsitemap_image/xmlsitemap_image.info
@@ -0,0 +1,8 @@
+name = XML sitemap image
+description = Adds image links to the sitemap.
+package = XML sitemap
+core = 6.x
+dependencies[] = xmlsitemap_node
+dependencies[] = imagefield
+files[] = xmlsitemap_image.module
+files[] = xmlsitemap_image.install
diff --git a/xmlsitemap_image/xmlsitemap_image.module b/xmlsitemap_image/xmlsitemap_image.module
new file mode 100644
index 0000000..3ab7a2f
--- /dev/null
+++ b/xmlsitemap_image/xmlsitemap_image.module
@@ -0,0 +1,51 @@
+<?php
+
+/**
+ * Implements hook_query_xmlsitemap_generate_alter().
+ */
+function xmlsitemap_image_query_xmlsitemap_generate_alter(&$data, $sitemap) {
+  $data['SELECT'] .= ', x.id, x.type, x.subtype';
+}
+
+/**
+ * Implements hook_sitemap_element_alter() .
+ */
+function xmlsitemap_image_sitemap_element_alter(&$element, $link) {
+  if ($link['type'] === 'node') {
+    $fields = _content_type_info();
+    
+    if (! empty($fields['content types'][$link['subtype']]['fields'])) {
+      foreach ($fields['content types'][$link['subtype']]['fields'] as $fieldname => $field) {
+        if ($field['widget']['type'] === 'imagefield_widget') {
+          $db_info = content_database_info($field);
+          $column = $db_info['columns']['fid']['column'];
+          $data = $db_info['columns']['data']['column'];
+          $result = db_query("SELECT c.*, f.* FROM {{$db_info['table']}} c INNER JOIN {node} n ON c.vid = n.vid AND n.nid = %d INNER JOIN {files} f ON c.$column = f.fid", $link['id']);
+          
+          while ($file = db_fetch_object($result)) {
+            $file->data = @unserialize($file->$data);
+            $element[] = xmlsitemap_image_create_tag($file);
+          }   
+        }
+      }
+    }
+  }
+}
+
+function xmlsitemap_image_create_tag($file) {
+  $title = $file->filename;
+  
+  if (! empty($file->data['title'])) {
+    $title = $file->data['title'];
+  }
+  elseif (! empty($file->data['alt'])) {
+    $title = $file->data['alt'];
+  }
+  
+  return array(
+    'image:image' => array(
+      'image:loc' => file_create_url($file->filepath),
+      'image:title' => $title,
+    ),
+  );
+}
diff --git a/xsl/xmlsitemap.xsl b/xsl/xmlsitemap.xsl
index f7ff8ec..2608681 100644
--- a/xsl/xmlsitemap.xsl
+++ b/xsl/xmlsitemap.xsl
@@ -26,6 +26,7 @@
 <xsl:stylesheet version="2.0"
     xmlns:html="http://www.w3.org/TR/REC-html40"
     xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
+    xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:output method="html" version="1.0" encoding="utf-8" indent="yes"/>
   <!-- Root template -->
@@ -93,6 +94,7 @@
           <th>Last modification date</th>
           <th>Change frequency</th>
           <th>Priority</th>
+          <th>Images</th>
         </tr>
       </thead>
       <tbody>
@@ -121,9 +123,24 @@
           <xsl:otherwise>0.5</xsl:otherwise>
         </xsl:choose>
       </td>
+      <td>
+        <xsl:if test="image:image">
+          <ul>
+            <xsl:apply-templates select="image:image">
+              <xsl:sort select="image:title" order="ascending"/>
+            </xsl:apply-templates>
+          </ul>
+        </xsl:if>
+      </td>
     </tr>
   </xsl:template>
 
+  <!-- image:image template -->
+  <xsl:template match="image:image">
+    <xsl:variable name="imageURL"><xsl:value-of select="image:loc"/></xsl:variable>
+    <li><a href="{$imageURL}"><xsl:value-of select="image:title"/></a></li>
+  </xsl:template>
+
   <!-- sitemap:sitemap template -->
   <xsl:template match="sitemap:sitemap">
     <tr>
