Copied to clipboard

Flag this post as spam?

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


  • Darren Hunter 140 posts 232 karma points
    Jun 02, 2023 @ 08:31
    Darren Hunter
    0

    Referenced by the following items on media type.

    Hi,

    I am trying to build my own Media Manager in Umbraco V10 Back office and have hit a wall, I can see when you go in to the back office and look at a media item it will show you the content the items used on.

    enter image description here

    Per the above screen shot but I am struggling to replicate this in my own code, it hit or mise it it works on not.

    We can't go through 100s of images and check there property's one by one to see if they are in use.

    I created my own dash board to do this, but I can't find any documentation on how to check what nodes a media items used on.

    Can someone point me in the correct direction please.

    here my search code as it stands at the moment:

    string searchTerm = "";

            var searchString = "";
    
            searchTerm = media.Key.ToString();
    
            searchString = "umb://media/" + searchTerm.Replace("-", string.Empty);
            IEnumerable<PublishedSearchResult> useInPagePart = Search(searchString);
    
            IEnumerable<IMedia> useInPage = _MediaService.GetAncestors(media);
    
            searchTerm = media.Key.ToString();  
            searchString = "*umb://media/" + searchTerm.Replace("-", string.Empty) + "*";
            IEnumerable<PublishedSearchResult> searchresults = Search(searchString);
    
            string contentName = "";
            string checkString = "Folder";
            Boolean foundFound = false;
    
    
            foreach (var item in useInPagePart)
            {
                contentName = item.Content.GetType().Name.ToString();
                foundFound = contentName.Contains(checkString);
    
                if (!foundFound)
                {
                    pageObjectList.Add(item.Content.Name, item.Content.Id);
                }
    
            }
    
            foreach (var item in searchresults)
            {
                contentName = item.Content.GetType().Name.ToString();
                foundFound = contentName.Contains(checkString);
    
                if (!foundFound)
                {
                    pageObjectList.Add(item.Content.Name, item.Content.Id);
                }
    
            }
    
            foreach (var item in useInPage)
            {
                contentName = item.ContentType.Name.ToString();
                foundFound = contentName.Contains(checkString);
    
                if (!foundFound)
                {
                    pageObjectList.Add(item.Name, item.Id);
                }
            }
    

    But it not returning all the results where am I going wrong.

  • Ismael 71 posts 354 karma points
    Jun 21, 2023 @ 03:15
    Ismael
    0

    Hi,

    I might be wrong, but I think that info is stored in the Relations table, so you might be able to use the Relation API to grab it?

    Cheers

Please Sign in or register to post replies

Write your reply to:

Draft