using Umbraco.Cms.Core.Configuration.Models; namespace Umbraco.Extensions; public static class ContentSettingsExtensions { /// /// Determines if file extension is allowed for upload based on (optional) white list and black list /// held in settings. /// Allow upload if extension is whitelisted OR if there is no whitelist and extension is NOT blacklisted. /// public static bool IsFileAllowedForUpload(this ContentSettings contentSettings, string extension) => contentSettings.AllowedUploadedFileExtensions.Any(x => x.InvariantEquals(extension)) || (contentSettings.AllowedUploadedFileExtensions.Any() == false && contentSettings.DisallowedUploadedFileExtensions.Any(x => x.InvariantEquals(extension)) == false); /// /// Gets the auto-fill configuration for a specified property alias. /// /// /// The property type alias. /// The auto-fill configuration for the specified property alias, or null. public static ImagingAutoFillUploadField? GetConfig(this ContentSettings contentSettings, string propertyTypeAlias) { ImagingAutoFillUploadField[] autoFillConfigs = contentSettings.Imaging.AutoFillImageProperties; return autoFillConfigs?.FirstOrDefault(x => x.Alias == propertyTypeAlias); } }