php-sitemap-generator
php-sitemap-generator copied to clipboard
Support multiple images for a single page.
Hi,
As per Google specification for image sitemaps, it is possible to have multiple images (up to 1000) for a single page.
You may find the example below:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
<url>
<loc>http://example.com/sample1.html</loc>
<image:image>
<image:loc>http://example.com/image.jpg</image:loc>
</image:image>
<image:image>
<image:loc>http://example.com/photo.jpg</image:loc>
</image:image>
</url>
<url>
<loc>http://example.com/sample2.html</loc>
<image:image>
<image:loc>http://example.com/picture.jpg</image:loc>
</image:image>
</url>
</urlset>
The current implementation assumes passing a single 'google_image' key into the extension parameter, not allowing to pass an array of multiple 'google_image' elements, making it impossible to have multiple images added for a single path.
The proposed solution would be, in addition to accepting a flattened array (preserving backward compatibility), to allow passing an array of multiple image/video elements. Please refer to example below:
$extensions = [
['google_image' => ['loc' => 'https://www.example.com/thumbs/1.jpg']],
['google_image' => ['loc' => 'https://www.example.com/thumbs/2.jpg']],
['google_image' => ['loc' => 'https://www.example.com/thumbs/3.jpg']]
];
Thanks, Ilya