Open Media Library from Sitecore Page Editor

This article describes how you can add your own button to the Sitecore Page Editor.

In a previous post I explained how to edit hidden fields in the Page Editor. This post is about managing media contents, and to do so you need to open the Sitecore Media Library which is the best tool for managing ALT texts, image descriptions and so on.

Open Media Library from the Sitecore Page Editor

Open Media Library from the Sitecore Page Editor

To open the Media Library you first need to add a button to the Page Editor. Go to the CORE database and find the Web Edit application at /sitecore/content/Applications/WebEdit.

The Preview and the Web Edit has their own individual toolbars, at /sitecore/content/Applications/WebEdit/Ribbons/Preview and /sitecore/content/Applications/WebEdit/Ribbons/WebEdit, so if you like the button to be visible in either mode you add the button twice.

  • Add a new Strip template below the toolbars to create a new tab.
  • Add a new Chunk template below the Strip template to create a new section on the strip.
  • Add a new Large Button template below the Chunk template to create a new button on the chunk.
  • Find a suitable icon and in the “click” field, write “webedit:OpenMediaLibrary
New button to open media library

New button to open media library

Now on to the code. First you need to couple the webedit:OpenMediaLibrary to the underlying code. This is done by adding a new .config file below /app_config/include, and add the following contents:

<configuration xmlns:patch="" xmlns:x="">
      <command name="webedit:OpenMediaLibrary" type="MyCode.OpenMediaLibrary,MyDll"/>

The code to open the media library looks like this:

using Sitecore;
using Sitecore.Text;
using Sitecore.Web.UI.Sheer;
using Sitecore.Shell.Framework.Commands;

namespace MyCode

  public class OpenMediaLibrary : Command
    public override void Execute([NotNull] CommandContext context)
      var url = new UrlString("/sitecore/shell/Applications/Content Manager/default.aspx");
      var header = string.Empty;
      var applicationItem = Client.CoreDatabase.GetItem("{7B2EA99D-BA9D-45B8-83B3-B38ADAD50BB8}");
      if (applicationItem != null)
        header = applicationItem["Display name"];
      if (header.Length == 0)
        header = "Media Library";
      url.Add("he", header);
      url.Add("pa", "1");
      url.Add("ic", "Applications/16x16/photo_scenery.png");
      url.Add("mo", "media");
      url.Add("ro", ItemIDs.MediaLibraryRoot.ToString());
      SheerResponse.Eval("'" + url + "', 'MediaLibrary', 'location=0,resizable=1')");

Thats it. You will now have access to the Media Library from the Page Editor.


About briancaos

Developer at Pentia A/S since 2003. Have developed Web Applications using Sitecore Since Sitecore 4.1.
This entry was posted in c#, General .NET, Sitecore 6 and tagged , , , , , . Bookmark the permalink.

5 Responses to Open Media Library from Sitecore Page Editor

  1. Pingback: Open Sitecore Content Editor from the Page Editor « Brian Pedersen’s Sitecore and .NET Blog

  2. Pingback: Sitecore 7 is comming: My wish list for Sitecore 7.01 | Brian Pedersen's Sitecore and .NET Blog

  3. subzerobear says:

    This works great, but is there a way to hide the content editor tab and worbox? I just want the editor to see just the media library.


  4. Note based on my testing: This doe not work with the SPEAK based menu/ribbon in version 8. The click-field has no effect.
    Instead follow:
    And use javascript-part from here to open the media library


  5. Pingback: Which of my old Sitecore posts are still valid in Sitecore 9? | Brian Pedersen's Sitecore and .NET Blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.