Sitecore has several templates it uses for items uploaded into the Media Library that can all be found at /sitecore/templates/System/Media. There are templates for all media types--documents, images, files, and more.

As part of a custom integration project for a client, I needed to add some custom fields on to items added into the Media Library from a third party system. I didn't want these fields present on items uploaded through the Media Library, so I chose to make new templates that inherit from these built-in media templates with the additional fields tacked on.

After I created these templates and imported some items with them, I was surprised to find that they would not show up in the Media Library Browser. In this post I'll outline how to fix that.

Copy Custom Media Templates to Core Database

If you switch over to the core database and navigate to /sitecore/templates/System/Media, you'll find that exact copies of all of the templates in the same location of the master database exist here too.

You need to copy your custom media item templates over to the core database as well. Open the Sitecore Control Panel, and click Move an item to another database in the Database section. Follow the wizard to copy your templates over to the core database. I recommend placing them in the same folder structure that you have in your master database to make them easier to find in the future, but it doesn't really matter. Note that this wizard actually copies your items over, it doesn't delete them from the master database as the name implies.

It's important that you copy your templates to the core database exactly as they are in the master database, down to the same ID.

If your custom media item templates derive from one of the built-in media item templates found under /sitecore/templates/System/Media, your items should start to show up in the Media Library Browser.

If your custom media item templates do not derive from one of the built-in media item templates found under /sitecore/templates/System/Media, this is only part of the story. Keep reading.

Why Duplicate the Templates?

It may seem strange for these templates to be duplicated, but the presence of these templates in the core database drive what types of items are displayed in the Media Library Browser. If you inspect network traffic when you do a search in the Media Library Browser, you'll see a request made to the following URL:

http://sitecoredemo.localhost/-/item/v1/sitecore/shell?facetsRootItemId=%7B7F43D3D0-CAC6-45D8-96FE-B76F4A117F9B%7D&search=cover&root=%7B3D6658D8-A0BF-4E75-B3E2-D050FABCF4E1%7D&searchConfig=%7BB0DF45DF-EA31-4C11-9E34-98B41DF549C5%7D&sc_content=master&language=en&format=%24convert_date_to_friendly_format&fields=__Created%7CDimensions&pageIndex=0&pageSize=20

The key is the searchConfig parameter in the query string. If you lookup the item {B0DF45DF-EA31-4C11-9E34-98B41DF549C5} in the core database, you'll find an item called AllMediaFiles located under /sitecore/client/Applications/Dialogs/SelectMediaDialog/PageSettings/SearchConfigs. The Media Library Browser uses this item to filter its search to only items found under sitecore/media library (see the Root field) and only items that inherit from the /system/templates/media/unversioned/file or /system/templates/media/versioned/file templates (see the Base Templates field), which all templates under /system/templates/media inherit from.

This search config item only knows about items in the core database, which is why all of the media item templates must be duplicated to core as well.

If your custom media item templates don't derive from one of the built-in file templates, you have to add them to the Base Templates field of the AllMediaFiles item. Now they will show up in the Media Library Browser.

Has this helped you out? Let me know in the comments. Cheers!