Setting Icons

Setting Icons

Icons Setting Options

  • Reference image files on the file system
  • Reference icon assets provided by Sitecore
  • Reference items in the Media Library 

File System Reference Steps

  1. Type the path to the image file in the icon "standard field" of the media item
    • Use "website" as the root
    • Reference a valid file type, such as .icon, .gif, .jpg, or .png
    • Reference an appropriate icon size; try a smaller version if icon fails to appear
    • Example: /images/TIC/buttons/feed-icon16x16.png

Icon Assets Reference Steps

  1. Click the Open Icon command in the field header of the icon "standard field"
  2. Select "icons" on the left side of the icon selection window
  3. Select the category of icon from the droplist on the right side of the icon selection window
  4. Select the icon directly from the icon library
    • A path to the icon will appear in the icon "standard field" text box
    • Example: software/32x32/text_code_colored.png

Media Library Reference Steps

  1. Paste the following into the icon "standard field" of the media item
    • https://ticdevs.com:443/~/media/11111111111111111111111111111111.ashx?h=16&thn=1&w=16
  2. Replace the 1111... with the Item ID of the media item from the Quick Info section
    • Example: {2B549716-0108-4C29-9CBE-8E18D7C70F7B}
  3. Remove the curly braces and dashes from the Item ID (aka GUID)
    • https://ticdevs.com:443/~/media/2B54971601084C299CBE8E18D7C70F7B.ashx?h=16&thn=1&w=16

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Configuration.Factory
  • Sitecore.Data.Database
  • Sitecore.Data.Items.Item
  • Sitecore.Diagnostics.Log
  • System.Exception
  • Sitecore.SecurityModel.SecurityDisabler

Setting Icons C# Web Control Code

Sitecore.Data.Database db = Sitecore.Configuration.Factory.GetDatabase("master");

{
item.Editing.BeginEdit();
try
{
item.Appearance.Icon = "Business/16x16/address_book.png"; 
Sitecore.Diagnostics.Log.Info("Icon successfully updated", this);
}

throw (ex);
}

Notes

  • Use a security disabler to allow changes and place in a using block to ensure cleanup occurs
  • There is no real-time output for this code
  • This control is not bound to this page