mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Fixing potential NRE in media profiles
This commit is contained in:
@@ -8,7 +8,6 @@ using Orchard.Forms.Services;
|
||||
using Orchard.Localization;
|
||||
using Orchard.MediaProcessing.Descriptors.Filter;
|
||||
using Orchard.MediaProcessing.Services;
|
||||
using Orchard.Utility.Extensions;
|
||||
|
||||
namespace Orchard.MediaProcessing.Providers.Filters {
|
||||
public class ResizeFilter : IImageFilterProvider {
|
||||
@@ -72,7 +71,7 @@ namespace Orchard.MediaProcessing.Providers.Filters {
|
||||
if (context.Media.CanSeek) {
|
||||
context.Media.Seek(0, SeekOrigin.Begin);
|
||||
}
|
||||
ImageBuilder.Current.Build(context.Media, result, settings);
|
||||
ImageBuilder.Current.Build(context.Media, result, settings, true);
|
||||
context.Media = result;
|
||||
}
|
||||
|
||||
|
@@ -110,6 +110,10 @@ namespace Orchard.MediaProcessing.Services {
|
||||
|
||||
var filterContext = new FilterContext { Media = image, FilePath = _storageProvider.Combine("_Profiles", _storageProvider.Combine(profileName, CreateDefaultFileName(path))) };
|
||||
|
||||
if (image == null) {
|
||||
return filterContext.FilePath;
|
||||
}
|
||||
|
||||
var tokens = new Dictionary<string, object>();
|
||||
// if a content item is provided, use it while tokenizing
|
||||
if (contentItem != null) {
|
||||
@@ -160,14 +164,18 @@ namespace Orchard.MediaProcessing.Services {
|
||||
|
||||
// TODO: Update this method once the storage provider has been updated
|
||||
private Stream GetImage(string path) {
|
||||
if (path == null) {
|
||||
throw new ArgumentNullException("path");
|
||||
}
|
||||
|
||||
var storagePath = _storageProvider.GetStoragePath(path);
|
||||
if (storagePath != null) {
|
||||
try {
|
||||
var file = _storageProvider.GetFile(storagePath);
|
||||
return file.OpenRead();
|
||||
}
|
||||
catch {
|
||||
Logger.Error("path:" + path + " storagePath:" + storagePath);
|
||||
catch(Exception e) {
|
||||
Logger.Error(e, "path:" + path + " storagePath:" + storagePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user