Skip to content

Commit 8b2a3f4

Browse files
Let UmbracoMediaUrl fallback to UmbracoMediaPath when empty
1 parent 7b6539f commit 8b2a3f4

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

src/Umbraco.Core/Configuration/Models/GlobalSettings.cs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,26 @@ public class GlobalSettings
2424
internal const string StaticUmbracoCssPath = "~/css";
2525
internal const string StaticUmbracoScriptsPath = "~/scripts";
2626
internal const string StaticUmbracoMediaPath = "~/media";
27-
internal const string StaticUmbracoMediaUrl = "~/media";
2827
internal const bool StaticInstallMissingDatabase = false;
2928
internal const bool StaticDisableElectionForSingleServer = false;
3029
internal const string StaticNoNodesViewPath = "~/umbraco/UmbracoWebsite/NoNodes.cshtml";
3130
internal const string StaticSqlWriteLockTimeOut = "00:00:05";
3231
internal const bool StaticSanitizeTinyMce = false;
3332

3433
/// <summary>
35-
/// Gets or sets a value for the reserved URLs.
36-
/// It must end with a comma
34+
/// Gets or sets a value for the reserved URLs (must end with a comma).
3735
/// </summary>
3836
[DefaultValue(StaticReservedUrls)]
3937
public string ReservedUrls { get; set; } = StaticReservedUrls;
4038

4139
/// <summary>
42-
/// Gets or sets a value for the reserved paths.
43-
/// It must end with a comma
40+
/// Gets or sets a value for the reserved paths (must end with a comma).
4441
/// </summary>
4542
[DefaultValue(StaticReservedPaths)]
4643
public string ReservedPaths { get; set; } = StaticReservedPaths;
4744

4845
/// <summary>
49-
/// Gets or sets a value for the timeout
46+
/// Gets or sets a value for the back-office login timeout.
5047
/// </summary>
5148
[DefaultValue(StaticTimeOut)]
5249
public TimeSpan TimeOut { get; set; } = TimeSpan.Parse(StaticTimeOut);
@@ -110,12 +107,10 @@ public class GlobalSettings
110107
[DefaultValue(StaticUmbracoMediaPath)]
111108
public string UmbracoMediaPath { get; set; } = StaticUmbracoMediaPath;
112109

113-
114110
/// <summary>
115-
/// Gets or sets a value for the Umbraco media url. Starts with "~/".
111+
/// Gets or sets a value for the Umbraco media URL (falls back to <see cref="UmbracoMediaPath" /> when empty).
116112
/// </summary>
117-
[DefaultValue(StaticUmbracoMediaUrl)]
118-
public string UmbracoMediaUrl { get; set; } = StaticUmbracoMediaUrl;
113+
public string UmbracoMediaUrl { get; set; }
119114

120115
/// <summary>
121116
/// Gets or sets a value indicating whether to install the database when it is missing.
@@ -139,6 +134,9 @@ public class GlobalSettings
139134
/// </summary>
140135
public string MainDomLock { get; set; } = string.Empty;
141136

137+
/// <summary>
138+
/// Gets or sets the telemetry ID.
139+
/// </summary>
142140
public string Id { get; set; } = string.Empty;
143141

144142
/// <summary>
@@ -172,18 +170,18 @@ public class GlobalSettings
172170
/// </summary>
173171
public bool IsPickupDirectoryLocationConfigured => !string.IsNullOrWhiteSpace(Smtp?.PickupDirectoryLocation);
174172

175-
/// Gets a value indicating whether TinyMCE scripting sanitization should be applied
173+
/// <summary>
174+
/// Gets a value indicating whether TinyMCE scripting sanitization should be applied.
176175
/// </summary>
177176
[DefaultValue(StaticSanitizeTinyMce)]
178177
public bool SanitizeTinyMce => StaticSanitizeTinyMce;
179178

180179
/// <summary>
181-
/// An int value representing the time in milliseconds to lock the database for a write operation
180+
/// Gets a value representing the time in milliseconds to lock the database for a write operation.
182181
/// </summary>
183182
/// <remarks>
184-
/// The default value is 5000 milliseconds
183+
/// The default value is 5000 milliseconds.
185184
/// </remarks>
186-
/// <value>The timeout in milliseconds.</value>
187185
[DefaultValue(StaticSqlWriteLockTimeOut)]
188186
public TimeSpan SqlWriteLockTimeOut { get; } = TimeSpan.Parse(StaticSqlWriteLockTimeOut);
189187
}

src/Umbraco.Core/DependencyInjection/UmbracoBuilder.Configuration.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,25 @@ namespace Umbraco.Cms.Core.DependencyInjection
1313
public static partial class UmbracoBuilderExtensions
1414
{
1515

16-
private static IUmbracoBuilder AddUmbracoOptions<TOptions>(this IUmbracoBuilder builder)
16+
private static IUmbracoBuilder AddUmbracoOptions<TOptions>(this IUmbracoBuilder builder, Action<OptionsBuilder<TOptions>> configure = null)
1717
where TOptions : class
1818
{
1919
var umbracoOptionsAttribute = typeof(TOptions).GetCustomAttribute<UmbracoOptionsAttribute>();
20-
2120
if (umbracoOptionsAttribute is null)
2221
{
23-
throw new ArgumentException("typeof(TOptions) do not have the UmbracoOptionsAttribute");
22+
throw new ArgumentException($"{typeof(TOptions)} do not have the UmbracoOptionsAttribute.");
2423
}
2524

26-
27-
builder.Services.AddOptions<TOptions>()
28-
.Bind(builder.Config.GetSection(umbracoOptionsAttribute.ConfigurationKey),
29-
o => o.BindNonPublicProperties = umbracoOptionsAttribute.BindNonPublicProperties)
25+
var optionsBuilder = builder.Services.AddOptions<TOptions>()
26+
.Bind(
27+
builder.Config.GetSection(umbracoOptionsAttribute.ConfigurationKey),
28+
o => o.BindNonPublicProperties = umbracoOptionsAttribute.BindNonPublicProperties
29+
)
3030
.ValidateDataAnnotations();
3131

32-
return builder;
32+
configure?.Invoke(optionsBuilder);
33+
34+
return builder;
3335
}
3436

3537
/// <summary>
@@ -52,7 +54,13 @@ public static IUmbracoBuilder AddConfiguration(this IUmbracoBuilder builder)
5254
.AddUmbracoOptions<ContentSettings>()
5355
.AddUmbracoOptions<CoreDebugSettings>()
5456
.AddUmbracoOptions<ExceptionFilterSettings>()
55-
.AddUmbracoOptions<GlobalSettings>()
57+
.AddUmbracoOptions<GlobalSettings>(optionsBuilder => optionsBuilder.PostConfigure(options =>
58+
{
59+
if (string.IsNullOrEmpty(options.UmbracoMediaUrl))
60+
{
61+
options.UmbracoMediaUrl = options.UmbracoMediaPath;
62+
}
63+
}))
5664
.AddUmbracoOptions<HealthChecksSettings>()
5765
.AddUmbracoOptions<HostingSettings>()
5866
.AddUmbracoOptions<ImagingSettings>()

0 commit comments

Comments
 (0)