diff --git a/src/Umbraco.Core/Configuration/ContentSettingsExtensions.cs b/src/Umbraco.Core/Configuration/ContentSettingsExtensions.cs
index 21ebe55f2f..65f0d3f744 100644
--- a/src/Umbraco.Core/Configuration/ContentSettingsExtensions.cs
+++ b/src/Umbraco.Core/Configuration/ContentSettingsExtensions.cs
@@ -1,5 +1,4 @@
-using System;
-using System.Linq;
+using System.Linq;
using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Configuration.UmbracoSettings;
@@ -7,20 +6,6 @@ namespace Umbraco.Core.Configuration
{
public static class ContentSettingsExtensions
{
- ///
- /// Gets a value indicating whether the file extension corresponds to an image.
- ///
- /// The file extension.
- ///
- /// A value indicating whether the file extension corresponds to an image.
- public static bool IsImageFile(this ContentSettings contentConfig, string extension)
- {
- if (contentConfig == null) throw new ArgumentNullException(nameof(contentConfig));
- if (extension == null) return false;
- extension = extension.TrimStart('.');
- return contentConfig.Imaging.ImageFileTypes.InvariantContains(extension);
- }
-
///
/// Determines if file extension is allowed for upload based on (optional) white list and black list
/// held in settings.
diff --git a/src/Umbraco.Core/Configuration/Models/ContentImagingSettings.cs b/src/Umbraco.Core/Configuration/Models/ContentImagingSettings.cs
index 018936896c..506d9bc329 100644
--- a/src/Umbraco.Core/Configuration/Models/ContentImagingSettings.cs
+++ b/src/Umbraco.Core/Configuration/Models/ContentImagingSettings.cs
@@ -17,8 +17,6 @@ namespace Umbraco.Core.Configuration.Models
}
};
- public IEnumerable ImageFileTypes { get; set; } = new[] { "jpeg", "jpg", "gif", "bmp", "png", "tiff", "tif" };
-
public IEnumerable AutoFillImageProperties { get; set; } = DefaultImagingAutoFillUploadField;
private class ImagingAutoFillUploadField : IImagingAutoFillUploadField
diff --git a/src/Umbraco.Core/Media/IImageUrlGenerator.cs b/src/Umbraco.Core/Media/IImageUrlGenerator.cs
index f9e67cdd2b..7c77a34388 100644
--- a/src/Umbraco.Core/Media/IImageUrlGenerator.cs
+++ b/src/Umbraco.Core/Media/IImageUrlGenerator.cs
@@ -1,9 +1,12 @@
-using Umbraco.Core.Models;
+using System.Collections.Generic;
+using Umbraco.Core.Models;
namespace Umbraco.Core.Media
{
public interface IImageUrlGenerator
{
+ IEnumerable SupportedImageFileTypes { get; }
+
string GetImageUrl(ImageUrlGenerationOptions options);
}
}
diff --git a/src/Umbraco.Core/Media/ImageUrlGeneratorExtensions.cs b/src/Umbraco.Core/Media/ImageUrlGeneratorExtensions.cs
new file mode 100644
index 0000000000..f45357881a
--- /dev/null
+++ b/src/Umbraco.Core/Media/ImageUrlGeneratorExtensions.cs
@@ -0,0 +1,21 @@
+using System;
+
+namespace Umbraco.Core.Media
+{
+ public static class ImageUrlGeneratorExtensions
+ {
+ ///
+ /// Gets a value indicating whether the file extension corresponds to an image.
+ ///
+ /// The image URL generator implementation that provides detail on which image extension sare supported.
+ /// The file extension.
+ /// A value indicating whether the file extension corresponds to an image.
+ public static bool IsImageFile(this IImageUrlGenerator imageUrlGenerator, string extension)
+ {
+ if (imageUrlGenerator == null) throw new ArgumentNullException(nameof(imageUrlGenerator));
+ if (extension == null) return false;
+ extension = extension.TrimStart('.');
+ return imageUrlGenerator.SupportedImageFileTypes.InvariantContains(extension);
+ }
+ }
+}
diff --git a/src/Umbraco.Infrastructure/Media/ImageSharpImageUrlGenerator.cs b/src/Umbraco.Infrastructure/Media/ImageSharpImageUrlGenerator.cs
index 48ff16f85b..cfe542badc 100644
--- a/src/Umbraco.Infrastructure/Media/ImageSharpImageUrlGenerator.cs
+++ b/src/Umbraco.Infrastructure/Media/ImageSharpImageUrlGenerator.cs
@@ -1,4 +1,5 @@
-using System.Globalization;
+using System.Collections.Generic;
+using System.Globalization;
using System.Text;
using Umbraco.Core;
using Umbraco.Core.Media;
@@ -9,6 +10,8 @@ namespace Umbraco.Infrastructure.Media
{
public class ImageSharpImageUrlGenerator : IImageUrlGenerator
{
+ public IEnumerable SupportedImageFileTypes => new[] { "jpeg", "jpg", "gif", "bmp", "png" };
+
public string GetImageUrl(ImageUrlGenerationOptions options)
{
if (options == null) return null;
diff --git a/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs b/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs
index 762e418441..d34b0bf0a0 100644
--- a/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs
+++ b/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs
@@ -1,13 +1,11 @@
using System;
using System.Drawing;
using System.IO;
-using Microsoft.Extensions.Options;
using Umbraco.Core;
-using Umbraco.Core.Configuration;
-using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
+using Umbraco.Core.Media;
using Umbraco.Core.Models;
namespace Umbraco.Web.Media
@@ -19,16 +17,16 @@ namespace Umbraco.Web.Media
{
private readonly IMediaFileSystem _mediaFileSystem;
private readonly ILogger _logger;
- private readonly ContentSettings _contentSettings;
+ private readonly IImageUrlGenerator _imageUrlGenerator;
public UploadAutoFillProperties(
IMediaFileSystem mediaFileSystem,
ILogger logger,
- IOptions contentSettings)
+ IImageUrlGenerator imageUrlGenerator)
{
_mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
- _contentSettings = contentSettings.Value ?? throw new ArgumentNullException(nameof(contentSettings));
+ _imageUrlGenerator = imageUrlGenerator ?? throw new ArgumentNullException(nameof(imageUrlGenerator));
}
///
@@ -73,7 +71,7 @@ namespace Umbraco.Web.Media
using (var filestream = _mediaFileSystem.OpenFile(filepath))
{
var extension = (Path.GetExtension(filepath) ?? "").TrimStart('.');
- var size = _contentSettings.IsImageFile(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null;
+ var size = _imageUrlGenerator.IsImageFile(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null;
SetProperties(content, autoFillConfig, size, filestream.Length, extension, culture, segment);
}
}
@@ -107,7 +105,7 @@ namespace Umbraco.Web.Media
else
{
var extension = (Path.GetExtension(filepath) ?? "").TrimStart('.');
- var size = _contentSettings.IsImageFile(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null;
+ var size = _imageUrlGenerator.IsImageFile(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null;
SetProperties(content, autoFillConfig, size, filestream.Length, extension, culture, segment);
}
}
diff --git a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs
index d4c5130b21..4011c6dbf6 100644
--- a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs
+++ b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs
@@ -7,6 +7,7 @@ using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.Models;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
+using Umbraco.Core.Media;
using Umbraco.Core.Models;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
@@ -37,7 +38,8 @@ namespace Umbraco.Web.PropertyEditors
IDataTypeService dataTypeService,
ILocalizationService localizationService,
ILocalizedTextService localizedTextService,
- IShortStringHelper shortStringHelper)
+ IShortStringHelper shortStringHelper,
+ IImageUrlGenerator imageUrlGenerator)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
_mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem));
@@ -45,7 +47,7 @@ namespace Umbraco.Web.PropertyEditors
_dataTypeService = dataTypeService;
_localizationService = localizationService;
_localizedTextService = localizedTextService;
- _uploadAutoFillProperties = new UploadAutoFillProperties(_mediaFileSystem, logger, contentSettings);
+ _uploadAutoFillProperties = new UploadAutoFillProperties(_mediaFileSystem, logger, imageUrlGenerator);
}
///
diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs
index 0fea46f2d3..36638d36b8 100644
--- a/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs
+++ b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs
@@ -9,6 +9,7 @@ using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.Models;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
+using Umbraco.Core.Media;
using Umbraco.Core.Models;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Services;
@@ -33,7 +34,6 @@ namespace Umbraco.Web.PropertyEditors
private readonly IMediaFileSystem _mediaFileSystem;
private readonly ContentSettings _contentSettings;
private readonly IDataTypeService _dataTypeService;
- private readonly ILocalizationService _localizationService;
private readonly IIOHelper _ioHelper;
private readonly UploadAutoFillProperties _autoFillProperties;
@@ -48,17 +48,17 @@ namespace Umbraco.Web.PropertyEditors
ILocalizationService localizationService,
IIOHelper ioHelper,
IShortStringHelper shortStringHelper,
- ILocalizedTextService localizedTextService)
+ ILocalizedTextService localizedTextService,
+ IImageUrlGenerator imageUrlGenerator)
: base(logger, dataTypeService, localizationService, localizedTextService, shortStringHelper)
{
_mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem));
_contentSettings = contentSettings.Value ?? throw new ArgumentNullException(nameof(contentSettings));
_dataTypeService = dataTypeService;
- _localizationService = localizationService;
_ioHelper = ioHelper;
// TODO: inject?
- _autoFillProperties = new UploadAutoFillProperties(_mediaFileSystem, logger, contentSettings);
+ _autoFillProperties = new UploadAutoFillProperties(_mediaFileSystem, logger, imageUrlGenerator);
}
public bool TryGetMediaPath(string alias, object value, out string mediaPath)
diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/ImageCropperTest.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/ImageCropperTest.cs
index 77d7aead5e..cf91550fe5 100644
--- a/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/ImageCropperTest.cs
+++ b/src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/ImageCropperTest.cs
@@ -9,6 +9,7 @@ using Umbraco.Web.Models;
using System.Text;
using Umbraco.Core.Media;
using Umbraco.Extensions;
+using System.Collections.Generic;
namespace Umbraco.Tests.PropertyEditors
{
@@ -311,6 +312,8 @@ namespace Umbraco.Tests.PropertyEditors
internal class TestImageUrlGenerator : IImageUrlGenerator
{
+ public IEnumerable SupportedImageFileTypes => new[] { "jpeg", "jpg", "gif", "bmp", "png", "tiff", "tif" };
+
public string GetImageUrl(ImageUrlGenerationOptions options)
{
var imageProcessorUrl = new StringBuilder(options.ImageUrl ?? string.Empty);
diff --git a/src/Umbraco.Tests/Models/MediaXmlTest.cs b/src/Umbraco.Tests/Models/MediaXmlTest.cs
index 593a581f85..8c98c6c45e 100644
--- a/src/Umbraco.Tests/Models/MediaXmlTest.cs
+++ b/src/Umbraco.Tests/Models/MediaXmlTest.cs
@@ -35,7 +35,7 @@ namespace Umbraco.Tests.Models
var contentSettings = new ContentSettingsBuilder().Build();
var mediaFileSystem = new MediaFileSystem(Mock.Of(), scheme, logger, ShortStringHelper);
- var ignored = new FileUploadPropertyEditor(Mock.Of(), mediaFileSystem, Microsoft.Extensions.Options.Options.Create(contentSettings), DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper);
+ var ignored = new FileUploadPropertyEditor(Mock.Of(), mediaFileSystem, Microsoft.Extensions.Options.Options.Create(contentSettings), DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, ImageUrlGenerator);
var media = MockedMedia.CreateMediaImage(mediaType, -1);
media.WriterId = -1; // else it's zero and that's not a user and it breaks the tests
diff --git a/src/Umbraco.Tests/Routing/MediaUrlProviderTests.cs b/src/Umbraco.Tests/Routing/MediaUrlProviderTests.cs
index b134934ee9..7c03197df6 100644
--- a/src/Umbraco.Tests/Routing/MediaUrlProviderTests.cs
+++ b/src/Umbraco.Tests/Routing/MediaUrlProviderTests.cs
@@ -39,8 +39,8 @@ namespace Umbraco.Tests.Routing
var dataTypeService = Mock.Of();
var propertyEditors = new MediaUrlGeneratorCollection(new IMediaUrlGenerator[]
{
- new FileUploadPropertyEditor(logger, mediaFileSystemMock, Microsoft.Extensions.Options.Options.Create(contentSettings), dataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper),
- new ImageCropperPropertyEditor(logger, mediaFileSystemMock, Microsoft.Extensions.Options.Options.Create(contentSettings), dataTypeService, LocalizationService, IOHelper, ShortStringHelper, LocalizedTextService),
+ new FileUploadPropertyEditor(logger, mediaFileSystemMock, Microsoft.Extensions.Options.Options.Create(contentSettings), dataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, ImageUrlGenerator),
+ new ImageCropperPropertyEditor(logger, mediaFileSystemMock, Microsoft.Extensions.Options.Options.Create(contentSettings), dataTypeService, LocalizationService, IOHelper, ShortStringHelper, LocalizedTextService, ImageUrlGenerator),
});
_mediaUrlProvider = new DefaultMediaUrlProvider(propertyEditors, UriUtility);
}
diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs
index 08a1297cda..76ad9f4a7e 100644
--- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs
+++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs
@@ -129,6 +129,7 @@ namespace Umbraco.Tests.Testing
protected ILocalizationService LocalizationService => Factory.GetInstance();
protected ILocalizedTextService LocalizedTextService { get; private set; }
protected IShortStringHelper ShortStringHelper => Factory?.GetInstance() ?? TestHelper.ShortStringHelper;
+ protected IImageUrlGenerator ImageUrlGenerator => Factory.GetInstance();
protected IUmbracoVersion UmbracoVersion { get; private set; }
protected ITypeFinder TypeFinder { get; private set; }
diff --git a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs
index 755c0b3a3f..4f397c4a59 100644
--- a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs
+++ b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs
@@ -11,6 +11,7 @@ using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Hosting;
+using Umbraco.Core.Media;
using Umbraco.Core.WebAssets;
using Umbraco.Extensions;
using Umbraco.Web.BackOffice.Profiling;
@@ -41,6 +42,7 @@ namespace Umbraco.Web.BackOffice.Controllers
private readonly SecuritySettings _securitySettings;
private readonly IRuntimeMinifier _runtimeMinifier;
private readonly IAuthenticationSchemeProvider _authenticationSchemeProvider;
+ private readonly IImageUrlGenerator _imageUrlGenerator;
public BackOfficeServerVariables(
LinkGenerator linkGenerator,
@@ -55,7 +57,8 @@ namespace Umbraco.Web.BackOffice.Controllers
IOptions runtimeSettings,
IOptions securitySettings,
IRuntimeMinifier runtimeMinifier,
- IAuthenticationSchemeProvider authenticationSchemeProvider)
+ IAuthenticationSchemeProvider authenticationSchemeProvider,
+ IImageUrlGenerator imageUrlGenerator)
{
_linkGenerator = linkGenerator;
_runtimeState = runtimeState;
@@ -70,6 +73,7 @@ namespace Umbraco.Web.BackOffice.Controllers
_securitySettings = securitySettings.Value;
_runtimeMinifier = runtimeMinifier;
_authenticationSchemeProvider = authenticationSchemeProvider;
+ _imageUrlGenerator = imageUrlGenerator;
}
///
@@ -363,7 +367,7 @@ namespace Umbraco.Web.BackOffice.Controllers
{"appPluginsPath", _hostingEnvironment.ToAbsolute(Constants.SystemDirectories.AppPlugins).TrimEnd('/')},
{
"imageFileTypes",
- string.Join(",", _contentSettings.Imaging.ImageFileTypes)
+ string.Join(",", _imageUrlGenerator.SupportedImageFileTypes)
},
{
"disallowedUploadFiles",
diff --git a/src/Umbraco.Web.BackOffice/Controllers/ImagesController.cs b/src/Umbraco.Web.BackOffice/Controllers/ImagesController.cs
index 6f1b7fb037..8b5b675dae 100644
--- a/src/Umbraco.Web.BackOffice/Controllers/ImagesController.cs
+++ b/src/Umbraco.Web.BackOffice/Controllers/ImagesController.cs
@@ -1,10 +1,7 @@
using System;
using System.IO;
using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Options;
using Umbraco.Core;
-using Umbraco.Core.Configuration;
-using Umbraco.Core.Configuration.Models;
using Umbraco.Core.IO;
using Umbraco.Core.Media;
using Umbraco.Core.Models;
@@ -20,16 +17,13 @@ namespace Umbraco.Web.BackOffice.Controllers
public class ImagesController : UmbracoAuthorizedApiController
{
private readonly IMediaFileSystem _mediaFileSystem;
- private readonly ContentSettings _contentSettings;
private readonly IImageUrlGenerator _imageUrlGenerator;
public ImagesController(
IMediaFileSystem mediaFileSystem,
- IOptions contentSettings,
IImageUrlGenerator imageUrlGenerator)
{
_mediaFileSystem = mediaFileSystem;
- _contentSettings = contentSettings.Value;
_imageUrlGenerator = imageUrlGenerator;
}
@@ -62,7 +56,7 @@ namespace Umbraco.Web.BackOffice.Controllers
var ext = Path.GetExtension(imagePath);
// we need to check if it is an image by extension
- if (_contentSettings.IsImageFile(ext) == false)
+ if (_imageUrlGenerator.IsImageFile(ext) == false)
return NotFound();
//redirect to ImageProcessor thumbnail with rnd generated from last modified time of original media file
diff --git a/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs b/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs
index 34f0f0afd7..8b6a60d299 100644
--- a/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs
+++ b/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs
@@ -18,6 +18,7 @@ using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Mapping;
+using Umbraco.Core.Media;
using Umbraco.Core.Models;
using Umbraco.Core.Models.ContentEditing;
using Umbraco.Core.Models.Entities;
@@ -27,8 +28,6 @@ using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Querying;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Security;
-using Umbraco.Web.ContentApps;
-using Umbraco.Web.WebApi.Filters;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
using Umbraco.Extensions;
@@ -39,7 +38,6 @@ using Umbraco.Web.Common.Attributes;
using Umbraco.Web.Common.Exceptions;
using Umbraco.Web.ContentApps;
using Umbraco.Web.Models.ContentEditing;
-using Umbraco.Web.Security;
using Umbraco.Web.WebApi.Filters;
using Constants = Umbraco.Core.Constants;
@@ -65,6 +63,8 @@ namespace Umbraco.Web.BackOffice.Controllers
private readonly ISqlContext _sqlContext;
private readonly IContentTypeBaseServiceProvider _contentTypeBaseServiceProvider;
private readonly IRelationService _relationService;
+ private readonly IImageUrlGenerator _imageUrlGenerator;
+
public MediaController(
ICultureDictionary cultureDictionary,
ILogger logger,
@@ -83,7 +83,8 @@ namespace Umbraco.Web.BackOffice.Controllers
IRelationService relationService,
PropertyEditorCollection propertyEditors,
IMediaFileSystem mediaFileSystem,
- IHostingEnvironment hostingEnvironment)
+ IHostingEnvironment hostingEnvironment,
+ IImageUrlGenerator imageUrlGenerator)
: base(cultureDictionary, logger, shortStringHelper, eventMessages, localizedTextService)
{
_shortStringHelper = shortStringHelper;
@@ -101,6 +102,7 @@ namespace Umbraco.Web.BackOffice.Controllers
_propertyEditors = propertyEditors;
_mediaFileSystem = mediaFileSystem;
_hostingEnvironment = hostingEnvironment;
+ _imageUrlGenerator = imageUrlGenerator;
}
///
@@ -744,7 +746,7 @@ namespace Umbraco.Web.BackOffice.Controllers
if (contentTypeAlias == Constants.Conventions.MediaTypes.AutoSelect)
{
- if (_contentSettings.Imaging.ImageFileTypes.Contains(ext))
+ if (_imageUrlGenerator.SupportedImageFileTypes.Contains(ext))
{
mediaType = Constants.Conventions.MediaTypes.Image;
}
diff --git a/src/Umbraco.Web.BackOffice/Controllers/TinyMceController.cs b/src/Umbraco.Web.BackOffice/Controllers/TinyMceController.cs
index b62d6b6080..4bae8970bc 100644
--- a/src/Umbraco.Web.BackOffice/Controllers/TinyMceController.cs
+++ b/src/Umbraco.Web.BackOffice/Controllers/TinyMceController.cs
@@ -12,6 +12,7 @@ using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Hosting;
using Umbraco.Core.IO;
+using Umbraco.Core.Media;
using Umbraco.Core.Strings;
using Umbraco.Web.BackOffice.Filters;
using Umbraco.Web.Common.ActionsResults;
@@ -32,18 +33,20 @@ namespace Umbraco.Web.BackOffice.Controllers
private readonly IShortStringHelper _shortStringHelper;
private readonly ContentSettings _contentSettings;
private readonly IIOHelper _ioHelper;
+ private readonly IImageUrlGenerator _imageUrlGenerator;
public TinyMceController(
IHostingEnvironment hostingEnvironment,
IShortStringHelper shortStringHelper,
IOptions contentSettings,
- IIOHelper ioHelper
- )
+ IIOHelper ioHelper,
+ IImageUrlGenerator imageUrlGenerator)
{
_hostingEnvironment = hostingEnvironment;
_shortStringHelper = shortStringHelper;
_contentSettings = contentSettings.Value;
_ioHelper = ioHelper;
+ _imageUrlGenerator = imageUrlGenerator;
}
[HttpPost]
@@ -78,7 +81,7 @@ namespace Umbraco.Web.BackOffice.Controllers
var safeFileName = fileName.ToSafeFileName(_shortStringHelper);
var ext = safeFileName.Substring(safeFileName.LastIndexOf('.') + 1).ToLower();
- if (_contentSettings.IsFileAllowedForUpload(ext) == false || _contentSettings.Imaging.ImageFileTypes.Contains(ext) == false)
+ if (_contentSettings.IsFileAllowedForUpload(ext) == false || _imageUrlGenerator.SupportedImageFileTypes.Contains(ext) == false)
{
// Throw some error - to say can't upload this IMG type
return new UmbracoProblemResult("This is not an image filetype extension that is approved", HttpStatusCode.BadRequest);
diff --git a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs
index 7b2cc04652..bfb2448926 100644
--- a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs
+++ b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs
@@ -10,6 +10,7 @@ using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Hosting;
+using Umbraco.Core.Media;
using Umbraco.Core.WebAssets;
using Umbraco.Web.Features;
using Umbraco.Web.Mvc;
@@ -36,6 +37,7 @@ namespace Umbraco.Web.Editors
private readonly RuntimeSettings _settings;
private readonly SecuritySettings _securitySettings;
private readonly IRuntimeMinifier _runtimeMinifier;
+ private readonly IImageUrlGenerator _imageUrlGenerator;
internal BackOfficeServerVariables(
UrlHelper urlHelper,
@@ -48,7 +50,8 @@ namespace Umbraco.Web.Editors
IHostingEnvironment hostingEnvironment,
IOptions settings,
IOptions securitySettings,
- IRuntimeMinifier runtimeMinifier)
+ IRuntimeMinifier runtimeMinifier,
+ IImageUrlGenerator imageUrlGenerator)
{
_urlHelper = urlHelper;
_runtimeState = runtimeState;
@@ -61,6 +64,7 @@ namespace Umbraco.Web.Editors
_settings = settings.Value;
_securitySettings = securitySettings.Value;
_runtimeMinifier = runtimeMinifier;
+ _imageUrlGenerator = imageUrlGenerator;
}
///
@@ -147,7 +151,7 @@ namespace Umbraco.Web.Editors
{"appPluginsPath", _hostingEnvironment.ToAbsolute(Constants.SystemDirectories.AppPlugins).TrimEnd('/')},
{
"imageFileTypes",
- string.Join(",", _contentSettings.Imaging.ImageFileTypes)
+ string.Join(",", _imageUrlGenerator.SupportedImageFileTypes)
},
{
"disallowedUploadFiles",