See script on my GitHub:
https://github.com/panticz/magento/blob/master/scripts/mk_sitemap_images.php
\n"; echo "\n"; } function print_url($url, $date) { echo " \n"; } try { print_head(); $collection = Mage::getModel('catalog/product') ->getCollection() ->addAttributeToFilter('image', array('notnull' => '', 'neq' => 'no_selection')) ->setStoreId(1); foreach($collection as $product) { // get last product update $updatedAt = substr($product->getUpdatedAt(), 0, 10); // get main image $image = Mage::getModel('catalog/product_media_config')->getMediaUrl($product->getImage()); print_url($image, $updatedAt); // get additional images $gallery = Mage::getModel('catalog/product')->load($product->getId())->getMediaGalleryImages(); foreach ($gallery as $image) { print_url($image->getUrl(), $updatedAt); } } print_foot(); } catch (Exception $e) { Mage::printException($e); } ?> >\n"; echo " \n"; } function print_foot() { echo "$url \n"; echo "$date \n"; echo "monthly \n"; echo "0.3 \n"; echo "