The XML Image & Video Sitemap Creator class allows you to create specific sitemaps for image, video and other content. The sitemap contains additional <image> and <video> tags which are used by Google to improve the indexing performance of images and videos on a website. This class will crawl through an entire directory and subdirectory structure to index image and video files as configured in the configuration options of the class. It can also index other files by providing their specific file extensions.The landing page <loc> for a specific image or video will automatically be determined by the class by checking if one of the landing pages; like 'index.php' (as configured in the configuration options of the class) is present in the crawled directory. When not present the main landing page will be used.
![]() ![]() The most simple example which indexes the entire directory and subdirectory structure from the current working directory and writes it to a file:
include_once('xml_image_and_video_sitemap_creator.class.php');
$xml = new xmlsitemap;
$filecontent = $xml -> createsitemap();
if ($fp = fopen('sitemap.xml', 'wb')) {
fwrite($fp, utf8_encode($filecontent));
fclose($fp);
}
The API of the class:
// Create a new instance of the class
include_once('xml_image_and_video_sitemap_creator.class.php');
$xml = new xmlsitemap;
$xml -> XMLURL = 'http://www.test.com'; $xml -> Excludedir = array('thumbs', '_vti_cnf');
$xml -> Excludehtaccess = true; $xml -> XMLimages = array('gif', 'png');
$xml -> XMLvideos = array('vob', 'wmv');
$xml -> XMLothers = array('htm', 'html');
$xml -> XMLlandingpages = array('index.html','index.htm','index.php');
$xml -> Mainlandingpage = 'index.asp'; $xml -> createsitemap([serverpath]); $xml -> results(); An example script which is self explanatory is included with the class.
|
|||||||


