2013-10-03 204 views
0

我們可以將Sitecore的媒體選項默認背景顏色更改爲白色嗎?默認情況下它是黑色的。
Sitecore媒體選項默認背景顏色變化

否則當我需要圖像時,我必須說總是,背景顏色是白色。

Sitecore.Resources.Media.MediaUrlOptions mediaUrlOptions = new Sitecore.Resources.Media.MediaUrlOptions(this.GetCurrentDatabase, false) 
       { 
        Width = 480, 
        Height = 360, 
        BackgroundColor = System.Drawing.Color.White 
       }; 

http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2011/05/Media-Options-and-Query-String-Parameters-in-the-Sitecore-ASPNET-CMS.aspx

回答

3

此設置在web.config中應該做的伎倆:

<!-- MEDIA - DEFAULT IMAGE BACKGROUND COLOR 
     The default background color for dynamically resizing images to different aspect ratios than the originals. 
     Sitecore applies this background color only for image types that do not support transparency (image/jpeg, image/gif and image/bmp). 
     When resizing any other image types (including image/png), Sitecore always applies a transparent background. 
     You can specify a color name (such as Black or Red) or a hex color code (such as #CE55E2). 
     If you specify no value, Sitecore applies a black background color when resizing such images. 
     Default value: "" 
--> 
<setting name="Media.DefaultImageBackgroundColor" value="White" />