From 29c4d63fe311b91aace9376ed820b75447b717ba Mon Sep 17 00:00:00 2001 From: Tuhin Bepari Date: Sun, 25 Aug 2019 08:01:44 +0600 Subject: [PATCH] Single SiteMap for both image and page --- src/Jobs/SitemapGeneratorJob.php | 2 +- src/Services/SiteMap.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Jobs/SitemapGeneratorJob.php b/src/Jobs/SitemapGeneratorJob.php index f528f50..0d723b5 100644 --- a/src/Jobs/SitemapGeneratorJob.php +++ b/src/Jobs/SitemapGeneratorJob.php @@ -36,7 +36,7 @@ public function __construct() public function handle() { $siteMap = new SiteMap(); - $siteMap->page()->image(); + $siteMap->page(); } } \ No newline at end of file diff --git a/src/Services/SiteMap.php b/src/Services/SiteMap.php index 8e1625d..bb1e0a7 100644 --- a/src/Services/SiteMap.php +++ b/src/Services/SiteMap.php @@ -88,6 +88,10 @@ private function singlePage($url, $page) $url->addChild('lastmod', $page->getLastModifiedDate()); $url->addChild('changefreq', $page->getChangeFrequency()); $url->addChild('priority', $page->getPriority()); + foreach ($page->pageImages as $image) { + $imageXml = $url->addChild('image:image', '', static::ImageNs); + $this->singleImage($imageXml, $image); + } return $url; }