Copied to clipboard

Flag this post as spam?

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

  • Nick 38 posts 131 karma points
    Feb 26, 2016 @ 14:08

    Media items are lost from front end view until a sort is performed on the media folders in the backend media tree


    I have a strange behaviour on one of my Umbraco sites. I have a couple of razor macros that loop through folders and files in the media tree and writes out links to view the sub folders or link to the files.

    The macro is working fine on the site for a number of days but then for some unknown reason the macros can't find any items in the media tree. If I login to the backend of the site I can browse the media tree and see the files / folders are still there.

    I can 'Reload nodes' but this has no effect. Items are still not being displayed by the macro. However if i right click a folder in the media tree and choose 'Sort' then this makes the folder contents visible again in the macro output.

    I have to sort each folder in the media tree, sorting the top level folder does not mean content from sub folders is displayed.

    The site then runs fine for a few days and then it suddenly happens again and I have to sort all the folders.

    Please can anyone help work out what is causing this?

    Also is there any way to program the resorting of all folders in the media tree so I don't have to go through the manual process of sorting each folder in turn.



  • Nick 38 posts 131 karma points
    Mar 02, 2016 @ 08:21

    Can anyone help?

    Any reason why suddenly the macro doesn't return any media items until the media tree is sorted?

    The code for one of the macros that reads the media tree is as follows, as described above the code runs fine and then for an unknown reason it starts to return no results until the media tree is sorted.

    The site has been upgraded to 7.3.7 and is hosted on Windows Azure.

    The code for one of the affected macros that is querying the media tree is

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @{ var mediaId = 1062; }
    @if (mediaId != null)
        @* Get all the media item associated with the id passed in *@
        var media = Umbraco.Media(mediaId);
        var selection = media.Children("Folder");
        if (selection.Any())
            var count = selection.Count();
            var colitems = count / 3;
            var colmod = count % 3;
            if (colmod != 0)
                colitems += 1;
            var loopcount = 1;
            <!--<p>Count: @count @colitems</p>-->
            <div class="row">
                @foreach (var item in selection)
                    if (loopcount == 1)
                        @:<div class="col-sm-4">
                            @:<ul class="HomeFolderList">
                        <!--<h3><a href="javascript:showChildren(@item.Id);" title="@item.Name">@item.Name</a></h3>-->
                        <h3><a href="/GetCategory/[email protected]&[email protected](item.Name)" title="@item.Name">@item.Name</a></h3>
                        @* GetChildFolders(@item.Id)*@
                    loopcount += 1;
                    if (loopcount == colitems + 1)
                        loopcount = 1;
                @* end of for loop, check if we need to close the list and column *@
                @if (loopcount != colitems + 1 && loopcount != 1)
            </div><!-- / row -->
  • Nick 38 posts 131 karma points
    Mar 31, 2016 @ 11:34

    Update: to fix the missing media items issue go to the Developer section > Examine Management tab > Internal Indexer > Index Info and tools > Rebuild Index

    However it does not explain what is causing the corruption of the index to happen.

    Is it possible to schedule the rebuilding of the Examine Internal index? e.g. nightly ?

  • Gert 81 posts 288 karma points
    Jan 18, 2017 @ 15:45

    I had the same issue. Thanks for this solution. Really strange this happend.

  • Jebastin 42 posts 91 karma points
    Nov 29, 2018 @ 10:27

    Hey Nick,

    I'm also facing the same issue, but when I save the media folder it shows up in the front-end. Anyway, thanks for the temporary solution that it gets fixed when rebuilding the Examine index.

    Do you have any permanent solution that doesn't involve any manual work to fix this issue.

    Thanks, Jebastin J

Please Sign in or register to post replies

Write your reply to: