XML Sitemap with modules plugin

I use the modules plugin together with @pedroborges xml sitmap plugin. what is the best way to hide the modules, but to get the images from it?
I don’t want to display the …/modules/gallery-e323rf3 link. But it would be great if I can collect every image from the modules.

What is your preferred way in doing this?

Just realized, that I can ignore the modules by template

c::set('sitemap.ignored.templates', ['module.gallery', ...]);

But then also the images are gone… Is there a way to collect all images from children and grandchildren?

The problem is that the images don’t exist by themselves, but as part of a page object. So if you remove the page object, the images will be gone as well.

As far as I can see at a cursory glance, what you want to achieve is not possible without modifying the XML sitemap plugin code itself.

Actually, you don’t need to modify the plugin. Create a snippet as I explain here.

After creating the site/snippets/sitemap.page.php and copying the code from the plugin snippet, you will need to modify this part:

<?php foreach ($page->images() as $image) : ?>
<?php snippet('sitemap.image', compact('image')) ?>
<?php endforeach ?>

There you need to check if the page intendedTemplate is module.gallery and then get the images from the children pages (modules) if so. I never tried something like this but it should work.

Thanks alot @pedroborges. That seems to work quite nice.
I just added the following code to the snippet right after your foreach loop:

      $modules = $page->grandChildren()->visible()->filterBy('template', 'in', ['module.gallery', 'module.imagetext']);

      foreach($modules as $module) {
        foreach($module->images() as $image) {
          snippet('sitemap.image', compact('image'));

If someone have a better way, just let me know… for now this works for me.