I am currently working on image sitemap generation in sitecore.So i need all the images used in a particular url of a website.
Here i need to get the details of all the items where media item is used.. or else i need to find what are all the media items(images) used in an item(url) in sitecore.
I have tried to get the image field from an item and it is working fine but what i need is to get all the images that are used in the item which are added through presentation details.
Item currentitem = master.GetItem("/sitecore/content/International/Cars/New models/All new XC90");
public static string GetImageURL(Item currentItem)
{
string imageURL = string.Empty;
Sitecore.Data.Fields.ImageField imageField = currentItem.Fields["Image"];
if (imageField != null && imageField.MediaItem != null)
{
Sitecore.Data.Items.MediaItem image = new Sitecore.Data.Items.MediaItem(imageField.MediaItem);
imageURL = Sitecore.StringUtil.EnsurePrefix('/', Sitecore.Resources.Media.MediaManager.GetMediaUrl(image));
}
return imageURL;
}