Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello, how can I create a dynamic sitemap for images? :)
Hi Bob,
Do you want to create sitemap with all media ? What images should be in the sitemap ?
Thanks
Hi Alex, yes, I want to create a sitemap with all the images that are under the media folder...
Bob,
You can use this code, if you have only 2 levels of media:
var list = Umbraco.TypedMediaAtRoot(); foreach (var media in list) { if (media.Children != null && media.Children.Count() > 0) { foreach (var childMedia in media.Children) { <li><a href="@childMedia.Url">@childMedia.Name</a></li> } } else { <li><a href="@media.Url">@media.Name</a></li> } }
Thank you so much, Alex. The code you posted works.
The problem is that I've also to indicate which page is associated to the images.
The structure of the Image Sitemap (posted by Google) is:
<?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/sample.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> </urlset>
Ok, so you have to iterate over pages first, get all images on your pages and generate it to sitemap.
Yes
Bob, did you finish sitemap?
No, sorry but I don't know how to associate images with pages...
Do you have some media picker on your pages ?
Most of the pictures I render are sub-nodes of the page. Just a little number of images are render directly from the media picker of the page.
Bob, you need to iterate over all your pages, in this circle you need each image and paste it to your result.
Can you show your structure ?
Alex, sorry for my delay in this response but I was very busy with my work.
In yellow there are the images.
The photogallery use a Photogallery type. The others use a Image Cropper type.
Works?
Hi Biagio, nope, I don't undestrand how to iterate all my images in the structure that I posted...
Hello, a few years later... I'm looking for the same solution. How can I (as an bit of a layman) make a sitemap for images? This is what I want to achive: https://developers.google.com/search/docs/advanced/sitemaps/image-sitemaps
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Sitemap for images
Hello, how can I create a dynamic sitemap for images? :)
Hi Bob,
Do you want to create sitemap with all media ? What images should be in the sitemap ?
Thanks
Hi Alex, yes, I want to create a sitemap with all the images that are under the media folder...
Bob,
You can use this code, if you have only 2 levels of media:
Thank you so much, Alex. The code you posted works.
The problem is that I've also to indicate which page is associated to the images.
The structure of the Image Sitemap (posted by Google) is:
Ok, so you have to iterate over pages first, get all images on your pages and generate it to sitemap.
Yes
Bob, did you finish sitemap?
No, sorry but I don't know how to associate images with pages...
Do you have some media picker on your pages ?
Most of the pictures I render are sub-nodes of the page. Just a little number of images are render directly from the media picker of the page.
Bob, you need to iterate over all your pages, in this circle you need each image and paste it to your result.
Can you show your structure ?
Thanks
Alex, sorry for my delay in this response but I was very busy with my work.
In yellow there are the images.
The photogallery use a Photogallery type. The others use a Image Cropper type.
Works?
Hi Biagio, nope, I don't undestrand how to iterate all my images in the structure that I posted...
Hello, a few years later... I'm looking for the same solution. How can I (as an bit of a layman) make a sitemap for images? This is what I want to achive: https://developers.google.com/search/docs/advanced/sitemaps/image-sitemaps
is working on a reply...