我正在维护一个 Umbraco 站点,其中包含在图像处理器中实现的简单水印功能。这是通过我没有源代码的编译库在 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 的升级如何导致它停止工作?