Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Roberto Bianchi 137 posts 445 karma points c-trib
    Feb 18, 2016 @ 09:00
    Roberto Bianchi
    0

    Sitemap for images

    Hello, how can I create a dynamic sitemap for images? :)

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Feb 18, 2016 @ 21:54
    Alex Skrypnyk
    1

    Hi Bob,

    Do you want to create sitemap with all media ? What images should be in the sitemap ?

    Thanks

  • Roberto Bianchi 137 posts 445 karma points c-trib
    Feb 19, 2016 @ 08:01
    Roberto Bianchi
    0

    Hi Alex, yes, I want to create a sitemap with all the images that are under the media folder...

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Feb 19, 2016 @ 09:44
    Alex Skrypnyk
    1

    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>
        }
    }
    
  • Roberto Bianchi 137 posts 445 karma points c-trib
    Feb 19, 2016 @ 10:05
    Roberto Bianchi
    0

    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> 
    
  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Feb 19, 2016 @ 11:15
    Alex Skrypnyk
    1

    Ok, so you have to iterate over pages first, get all images on your pages and generate it to sitemap.

  • Roberto Bianchi 137 posts 445 karma points c-trib
    Feb 19, 2016 @ 13:56
    Roberto Bianchi
    0

    Yes

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Feb 19, 2016 @ 16:10
    Alex Skrypnyk
    1

    Bob, did you finish sitemap?

  • Roberto Bianchi 137 posts 445 karma points c-trib
    Feb 19, 2016 @ 16:12
    Roberto Bianchi
    0

    No, sorry but I don't know how to associate images with pages...

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Feb 19, 2016 @ 16:19
    Alex Skrypnyk
    1

    Do you have some media picker on your pages ?

  • Roberto Bianchi 137 posts 445 karma points c-trib
    Feb 19, 2016 @ 16:22
    Roberto Bianchi
    0

    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.

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Feb 19, 2016 @ 17:33
    Alex Skrypnyk
    1

    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

  • Roberto Bianchi 137 posts 445 karma points c-trib
    Feb 26, 2016 @ 09:54
    Roberto Bianchi
    0

    Alex, sorry for my delay in this response but I was very busy with my work.

    enter image description here

    In yellow there are the images.

    The photogallery use a Photogallery type. The others use a Image Cropper type.

  • Biagio Paruolo 1494 posts 1635 karma points c-trib
    Apr 20, 2016 @ 17:59
    Biagio Paruolo
    0

    Works?

  • Roberto Bianchi 137 posts 445 karma points c-trib
    Apr 21, 2016 @ 07:15
    Roberto Bianchi
    0

    Hi Biagio, nope, I don't undestrand how to iterate all my images in the structure that I posted...

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies