<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Deep sharma on Medium]]></title>
        <description><![CDATA[Stories by Deep sharma on Medium]]></description>
        <link>https://medium.com/@drs231999?source=rss-b43efcbc4a54------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mqpFKsx6qrb2vrAW9qt9Gw.jpeg</url>
            <title>Stories by Deep sharma on Medium</title>
            <link>https://medium.com/@drs231999?source=rss-b43efcbc4a54------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 02:38:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@drs231999/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building a Media Usage & Orphan Tracking Dashboard in Sitecore XM 10]]></title>
            <link>https://medium.com/@drs231999/building-a-media-usage-orphan-tracking-dashboard-in-sitecore-xm-10-cd85bdf69fe3?source=rss-b43efcbc4a54------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd85bdf69fe3</guid>
            <category><![CDATA[aspnet-development]]></category>
            <category><![CDATA[sitecore-development]]></category>
            <category><![CDATA[sitecore-xm]]></category>
            <category><![CDATA[media-management]]></category>
            <dc:creator><![CDATA[Deep sharma]]></dc:creator>
            <pubDate>Sun, 11 Jan 2026 15:53:31 GMT</pubDate>
            <atom:updated>2026-01-11T15:53:31.619Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone</p><p>While working on a <strong>Sitecore XM 10</strong> implementation, I noticed a common challenge most content-heavy projects face over time: <strong>media sprawl</strong>.</p><p>Editors struggle to answer simple questions like:</p><ul><li>Which images are actually used?</li><li>Which files are safe to delete?</li><li>Where is this PDF referenced?</li></ul><p>To solve this, I built a <strong>Media Usage &amp; Orphan Tracking dashboard</strong> inside Sitecore.</p><p>This post explains what the solution does and includes <strong>essential code snippets</strong> so you can implement it in your own Sitecore project.</p><h3>Solution Overview</h3><p>The dashboard provides:</p><ul><li>Linked vs orphan media detection</li><li>Expandable usage view (one media → many pages)</li><li>Search, filtering, and pagination</li><li>Excel export for reporting</li><li>Support for site-specific and shared media</li></ul><p>The implementation uses:</p><ul><li><strong>Sitecore XM 10</strong></li><li><strong>ASP.NET WebForms</strong></li><li><strong>Stored procedures for performance</strong></li><li><strong>EPPlus</strong> for Excel export</li></ul><h3>Step 1: Media Usage Model</h3><p>Create a model to represent a media item and its usage.</p><pre>[Serializable]<br>public class MediaItem<br>{<br>    public string ID { get; set; }<br>    public string Name { get; set; }<br>    public string MediaType { get; set; }<br>    public long Size { get; set; }<br>    public string Language { get; set; }<br>    public string IsPublished { get; set; }<br>    public string MediaPath { get; set; }<br>    public string IsLinked { get; set; }<br><br>    // Grouping &amp; UI helpers<br>    public bool IsGroupHeader { get; set; }<br>    public bool IsExpanded { get; set; }<br>    public int LinkedItemsCount { get; set; }<br>    public List&lt;MediaItem&gt; LinkedItems { get; set; }<br>}</pre><p>This model supports <strong>grouping</strong> and <strong>expand/collapse behavior</strong> in the UI.</p><h3>Step 2: Fetch Media Usage Data (Performance First)</h3><p>Avoid traversing the content tree at runtime.<br> Instead, fetch media usage via a <strong>stored procedure</strong>.</p><pre>DataSet ds = masterDatabase.ExecuteDataSet(<br>    &quot;storeProcedure&quot;,<br>    masterDatabase.CreateParameter(&quot;@par1&quot;, SqlDbType.NVarChar, par1),<br>    masterDatabase.CreateParameter(&quot;@par2&quot;, SqlDbType.NVarChar, par2),<br>    masterDatabase.CreateParameter(&quot;@par3&quot;, SqlDbType.NVarChar, par3)<br>);</pre><h3>Why stored procedures?</h3><ul><li>Faster execution</li><li>Cleaner C# code</li><li>Easy to optimize later</li><li>Scales well for large media libraries</li></ul><h3>Step 3: Map Raw Data to Strongly Typed Objects</h3><pre>var mediaItems = ds.Tables[0].AsEnumerable()<br>    .Select(row =&gt; new MediaItem<br>    {<br>        ID = row[&quot;ID&quot;].ToString(),<br>        Name = row[&quot;Name&quot;].ToString(),<br>        MediaType = row[&quot;Extension&quot;].ToString(),<br>        MediaPath = row[&quot;MediaPath&quot;].ToString(),<br>        IsLinked = row[&quot;LinkedStatus&quot;].ToString()<br>    })<br>    .ToList();</pre><p>This makes filtering, grouping, and exporting far easier.</p><h3>Step 4: Group Media by Usage</h3><p>Multiple pages can reference the same media item.<br> Instead of showing duplicates, group them.</p><pre>private List&lt;MediaItem&gt; GroupMediaItems(List&lt;MediaItem&gt; items)<br>{<br>    return items<br>        .GroupBy(x =&gt; x.ID)<br>        .Select(group =&gt;<br>        {<br>            var header = group.First();<br>            header.IsGroupHeader = true;<br>            header.LinkedItemsCount = group.Count();<br>            header.LinkedItems = group.ToList();<br>            return header;<br>        })<br>        .ToList();<br>}</pre><p>This enables:</p><ul><li>Expand / collapse UI</li><li>Clean presentation</li><li>Faster scanning for editors</li></ul><h3>Step 5: Filtering &amp; Search</h3><pre>var filtered = mediaItems<br>    .Where(x =&gt; x.Name.ToLower().Contains(searchText))<br>    .Where(x =&gt; status == &quot;All&quot; || x.IsLinked == status)<br>    .Where(x =&gt; type == &quot;All&quot; || x.MediaType == type)<br>    .ToList();</pre><p>This works seamlessly with pagination.</p><h3>Step 6: Server-Side Pagination</h3><pre>var pagedItems = filtered<br>    .Skip(currentPage * pageSize)<br>    .Take(pageSize)<br>    .ToList();</pre><p>Server-side pagination ensures:</p><ul><li>Consistent performance</li><li>Minimal memory usage</li><li>Smooth UX even with thousands of items</li></ul><h3>Step 7: Expand / Collapse Linked Items</h3><p>Track expanded rows using ViewState.</p><pre>bool isExpanded = expandedIds.Contains(mediaItem.ID);<br>mediaItem.IsExpanded = isExpanded;</pre><p>Nested repeaters display linked pages only when expanded.</p><h3>Step 8: Export to Excel (EPPlus)</h3><pre>using (var package = new ExcelPackage())<br>{<br>    var sheet = package.Workbook.Worksheets.Add(&quot;Media Usage&quot;);<br>    sheet.Cells[1, 1].Value = &quot;Media Name&quot;;<br>    sheet.Cells[1, 2].Value = &quot;Type&quot;;<br>    sheet.Cells[1, 3].Value = &quot;Linked Status&quot;;<br>    int row = 2;<br>    foreach (var item in mediaItems)<br>    {<br>        sheet.Cells[row, 1].Value = item.Name;<br>        sheet.Cells[row, 2].Value = item.MediaType;<br>        sheet.Cells[row, 3].Value = item.IsLinked;<br>        row++;<br>    }<br>    package.SaveAs(response.OutputStream);<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EK678wICRDmmPLTDyqHBTQ.png" /></figure><h3>Why This Approach Works</h3><p>✔ Fast (DB-driven)<br> ✔ Scalable<br> ✔ Editor-friendly<br> ✔ Production-safe<br> ✔ Easy to extend (delete unused media, bulk actions, etc.)</p><h3>Final Thoughts</h3><p>This Media Usage dashboard has become one of the <strong>most useful internal tools</strong> in our Sitecore projects. It dramatically improves <strong>content governance</strong> and <strong>editor confidence</strong>.</p><p>If you’re working with <strong>Sitecore XM 10</strong>, I highly recommend implementing something similar.</p><p>Happy Sitecore-ing</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd85bdf69fe3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>