Media Settings

Media Settings

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Configuration.Settings
  • Sitecore.Configuration.Settings.Media
  • Sitecore.Context
  • Sitecore.Data.Items.Item

Media Settings C# Web Control Code

Sitecore.Data.Items.Item item = Sitecore.Context.Item;
if (item == null) return;

string autoSetAlt = Sitecore.Configuration.Settings.Media.AutoSetAlt.ToString();
string mediaCacheFolder = Sitecore.Configuration.Settings.Media.CacheFolder;
string mediaCachingEnabled = Sitecore.Configuration.Settings.Media.CachingEnabled.ToString();
string defaultImageFormat = Sitecore.Configuration.Settings.Media.DefaultImageFormat;
string defaultMediaPrefix = Sitecore.Configuration.Settings.Media.DefaultMediaPrefix;
string mediaFileFolder = Sitecore.Configuration.Settings.Media.FileFolder;
string generateThumbnails = Sitecore.Configuration.Settings.GenerateThumbnails.ToString();
string includeExtInItemNames = Sitecore.Configuration.Settings.Media.IncludeExtensionsInItemNames.ToString();
string interpolationMode = Sitecore.Configuration.Settings.Media.InterpolationMode.ToString();
string maxImageWidth = Sitecore.Configuration.Settings.Media.MaxImageWidth.ToString();
string maxSizeInDatabase = Sitecore.Configuration.Settings.Media.MaxSizeInDatabase.ToString();
string maxSizeInMemory = Sitecore.Configuration.Settings.Media.MaxSizeInMemory.ToString();
string mediaLinkPrefix = Sitecore.Configuration.Settings.Media.MediaLinkPrefix;
string openContentEditorAfterUpload = Sitecore.Configuration.Settings.Media.OpenContentEditorAfterUpload.ToString();
string requestExtension = Sitecore.Configuration.Settings.Media.RequestExtension;
string streamBufferSize = Sitecore.Configuration.Settings.Media.StreamBufferSize.ToString();
string streamPartiallyCachedFiles = Sitecore.Configuration.Settings.Media.StreamPartiallyCachedFiles.ToString(); 
string useItemPaths = Sitecore.Configuration.Settings.Media.UseItemPaths.ToString();
string useLegacyResizing = Sitecore.Configuration.Settings.Media.UseLegacyResizing.ToString();
string whitespaceReplacement = Sitecore.Configuration.Settings.Media.WhitespaceReplacement;
string mediaFolder = Sitecore.Configuration.Settings.MediaFolder;

//media upload settings
string uploadAsFiles = Sitecore.Configuration.Settings.Media.UploadAsFiles.ToString();
string uploadAsVersionableByDefault = Sitecore.Configuration.Settings.Media.UploadAsVersionableByDefault.ToString();
string maximumDatabaseUploadSize = Sitecore.Configuration.Settings.Upload.MaximumDatabaseUploadSize.ToString();
string simpleUploadOverwriting = Sitecore.Configuration.Settings.Upload.SimpleUploadOverwriting.ToString();
string uploadClassic = Sitecore.Configuration.Settings.Upload.Classic.ToString();
string userSelectableDestination = Sitecore.Configuration.Settings.Upload.UserSelectableDestination.ToString();

//media response settings
string mediaCacheability = Sitecore.Configuration.Settings.MediaResponse.Cacheability.ToString();
string mediaCacheExtensions = Sitecore.Configuration.Settings.MediaResponse.CacheExtensions;
string mediaMaxAge = Sitecore.Configuration.Settings.MediaResponse.MaxAge.ToString();
string mediaSlidingExpiration = Sitecore.Configuration.Settings.MediaResponse.SlidingExpiration.ToString();

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.Write("C# Web Control Real-time Output");
output.RenderEndTag();

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-size:x-small; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
//using : for colon and ? for question mark and   for space
output.Write("{0}: {1}", "Item", item.DisplayName);
output.RenderEndTag(); //P

output.Write("{0}&#63;&#160;{1}", "AutoSetAlt", "<b>" + autoSetAlt + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Media Cache Folder", "<b>" + mediaCacheFolder + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Media Caching Enabled", "<b>" + mediaCachingEnabled + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Default Image Format", "<b>" + defaultImageFormat + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Default Media Prefix", "<b>" + defaultMediaPrefix + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Media File Folder", "<b>" + mediaFileFolder + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Generate Thumbnails", "<b>" + generateThumbnails + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Include Extensions In Item Names", "<b>" + includeExtInItemNames + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Interpolation Mode", "<b>" + interpolationMode + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Maximum Image Width", "<b>" + maxImageWidth + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Maximum Size In Database", "<b>" + maxSizeInDatabase + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Maximum Size In Memory", "<b>" + maxSizeInMemory + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Open Content Editor After Upload", "<b>" + openContentEditorAfterUpload + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Request Extension", "<b>" + requestExtension + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Stream Buffer Size", "<b>" + streamBufferSize + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Stream Partially Cached Files", "<b>" + streamPartiallyCachedFiles + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Use Item Paths", "<b>" + useItemPaths + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Use Legacy Resizing", "<b>" + useLegacyResizing + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Whitespace Replacement", "<b>" + whitespaceReplacement + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Media Folder", "<b>" + mediaFolder + "</b><br/>");

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
output.Write("{0}","Media Upload Settings");
output.RenderEndTag(); //P

output.Write("{0}&#58;&#160;{1}", "Maximum Database Upload Size", "<b>" + maximumDatabaseUploadSize + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Upload As Files", "<b>" + uploadAsFiles + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Upload As Versionable By Default", "<b>" + uploadAsVersionableByDefault + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Simple Upload Overwriting", "<b>" + simpleUploadOverwriting + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Upload in Classic Mode", "<b>" + uploadClassic + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "User Selectable Destination", "<b>" + userSelectableDestination + "</b><br/>");

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
output.Write("{0}", "Media Response Settings");
output.RenderEndTag(); //P

output.Write("{0}&#58;&#160;{1}", "Media Response Cacheability", "<b>" + mediaCacheability + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Media Response Cache Extensions", "<b>" + mediaCacheExtensions + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Media Response Maximum Age", "<b>" + mediaMaxAge + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Media Response Sliding Expiration", "<b>" + mediaSlidingExpiration + "</b>");

output.RenderEndTag(); //Div

 


Media Settings C# Web Control Output


AutoSetAlt? False
Media Cache Folder: /App_Data/MediaCache
Media Caching Enabled: True
Default Image Format: Jpeg
Default Media Prefix: ~/media/
Media File Folder: /App_Data/MediaFiles
Generate Thumbnails? True
Include Extensions In Item Names? False
Interpolation Mode: High
Maximum Image Width: 0
Maximum Size In Database: 524288000
Maximum Size In Memory: 41943040
Open Content Editor After Upload: True
Request Extension: ashx
Stream Buffer Size: 100000
Stream Partially Cached Files: True
Use Item Paths: True
Use Legacy Resizing: False
Whitespace Replacement:  
Media Folder: C:\inetpub\wwwroot\TIC66Live\Website\upload
Maximum Database Upload Size: 524083200
Upload As Files? False
Upload As Versionable By Default? False
Simple Upload Overwriting? False
Upload in Classic Mode? False
User Selectable Destination? True

Media Response Settings

Media Response Cacheability: Private
Media Response Cache Extensions: 
Media Response Maximum Age: 7.00:00:00
Media Response Sliding Expiration: Undefined