Sitecore Blog: @sitecorejohn blog

Media Options and Query String Parameters in the Sitecore ASP.NET CMS

By John West, May 03, 2011 | Rating:  | Comments (12)

This blog post lists the query string parameters used in URLs of media items in the Sitecore ASP.NET CMS.

The Presentation Component Reference manual on the Sitecore Developer Network (SDN) lists parameters that you can pass to the <sc:image> XSL control, which renders the HTML markup to display the image referenced in a field of type Image. Sitecore adds corresponding parameters to the query string of the URL for the media item.

Some of these query string parameters affect image aspects, such as sizing. Others apply to any type of media, such as language, version, database, and cache functionality.

Here is a list of the supported query string parameters:

  • w: Width in pixels
  • h: Height in pixels
  • mw: Maximum width in pixels
  • mh: Maximum height in pixels
  • la: Language (defaults to context language)
  • vs: Version (defaults to latest version)
  • db: Database name (defaults to context database)
  • bc: Background color (defaults to black)
  • as: Allow stretch (as=1)
  • sc: Scale by floating point number (sc=.25 = 25%)
  • thn: Thumbnail (thn=1)
  • dmc: Disable media caching, both retrieval and storage (dmc=1)

In general, avoid constructing URLs using these query string parameters explicitly. For example, use the Sitecore.Data.Items.Item.Appearance.Icon property to retrieve the icon, the Sitecore.Resources.Media.MediaManager.GetThumbnailUrl() method to retrieve the URL, or the Sitecore.Resources.Media.MediaManager.GetMediaUrl() method with the Sitecore.Resources.Media.MediaUrlOptions class to construct the URL programatically. Remember to use something like the Sitecore.StringUtil.EnsurePrefix() method to ensure that media URLs begin with a slash (/) rather than a tilde (~). Media URLs that begin with this character can result in multiple URLs for media items and sooner exceed IIS path length limits. You can download some sample code that shows these techniques.

Tags: API, Architecture


  • Very useful information. I found few more. What does it mean if my url contains querystring as &mo=preview&we=1. What is the purpose of sc_wede=1 in cookie

    - Shri Shri
    June 06, 2011 at 10:25 PM

  • I'd take a guess that we or wede is web edit and mo is mode.

    - mark stiles
    November 29, 2011 at 10:42 AM

  • Check out the Shared Source Module 'Image Cropper' by Igloo Digital. It allows a crop=1 parameter to trim the image so you don't get the letter boxing background.

    - Sean Holmesby
    January 25, 2012 at 9:11 PM

  • There is another parameter which can be used to convert the image in grayscale : gray=1

    - christophe Goasduff
    December 06, 2012 at 1:57 AM


    - John West
    March 01, 2013 at 10:11 AM

  • // bc: Background color (defaults to black) Can't we change this default colour to "White"?

    - Chackrapani Wickramarathne
    October 02, 2013 at 7:25 PM

  • My thought would be to try overriding the ResizeProcessor processor in the getMediaStream pipeline to set this to white if it is black (or maybe null). If you can check for null, that would be better because you might in some cases want black. If you cannot check for null and may need black, maybe disable your logic if bc appears in the query string.

    - John West
    October 08, 2013 at 9:11 AM


    - John West
    October 08, 2013 at 9:58 AM


    - John West
    October 21, 2013 at 6:21 PM


    - John West
    May 14, 2015 at 2:38 AM


    - John West
    January 14, 2016 at 12:48 PM

  • great article .

    - wasim wasim
    January 21, 2016 at 1:17 PM

*{0} must be filled in.
*{0} must be filled in.
*{0} must be filled in.