我正在维护一个Umbraco网站,该网站包含在Image Processor中实现的简单水印功能。这在Umbraco 7.4.2中通过未提供源代码的编译库工作。将Umbraco更新到7.12.3后,它将不再起作用。我正在寻找简单的解释或提示原因所在。
ImageProcessor和ImageProcessor.Web的版本保持不变(2.6.2.25和4.9.3.25),ImageProcessor.Web.Config(2.4.1.19)保持不变。
它似乎是在 \ config \ ImageProcessor \ processing.config文件如下:
<processing preserveExifMetaData="false" fixGamma="false" interceptAllRequests="true">
<presets>
</presets>
<plugins>
<plugin name="SecurityWatermark" type="MMUmbracoLibrary.Imaging.Web.Processors.SecurityWatermark, MMUmbracoLibrary">
<settings>
<setting key="WatermarkVirtualPath" value="~/app_data/watermark.png" />
</settings>
使用DotPeek查看库,我看到该方法的来源如下:
using ImageProcessor.Processors;
using ImageProcessor.Web.Processors;
using System.Text.RegularExpressions;
namespace MMUmbracoLibrary.Imaging.Web.Processors
{
public class SecurityWatermark : IWebGraphicsProcessor
{
private static readonly Regex QueryRegex = new Regex(".+", RegexOptions.Compiled);
public SecurityWatermark()
{
this.Processor = (IGraphicsProcessor) new MMUmbracoLibrary.Imaging.Processors.SecurityWatermark();
}
public Regex RegexPattern
{
get
{
return SecurityWatermark.QueryRegex;
}
}
public int SortOrder
{
get
{
return 0;
}
private set
{
}
}
public IGraphicsProcessor Processor { get; private set; }
public int MatchRegexIndex(string queryString)
{
return this.SortOrder;
}
}
}
另外,DotPeek的这段代码可能是最重要的部分:
namespace MMUmbracoLibrary.Imaging.Processors
{
public class SecurityWatermark : IGraphicsProcessor
{
public object DynamicParameter { get; set; }
public Dictionary<string, string> Settings { get; set; }
public Image ProcessImage(ImageFactory factory)
{
IMedia mediaByPath = ApplicationContext.Current.Services.MediaService.GetMediaByPath(HttpContext.Current.Request.Path);
if (mediaByPath == null)
throw new HttpException(404, "No image found");
if ((int) mediaByPath.Properties["disableWatermark"].Value != 0)
return factory.Image;
string filename = HttpContext.Current.Server.MapPath(this.Settings["WatermarkVirtualPath"]);
ImageLayer imageLayer = new ImageLayer()
{
Image = (Image) new Bitmap(filename),
Opacity = 100,
Size = factory.Image.Size
};
return factory.Overlay(imageLayer).Image;
}
}
}
说实话,这段代码对我来说没有多大意义,但它似乎可以工作。谁能建议Umbraco升级如何导致它停止工作?