Dean Leigh
08/10/2023, 7:28 AM@{
if (Model?.Areas.Any() != true) { return; }
var hasSettings = Model.Settings != null;
var backgroundColour = hasSettings ? Model.Settings.Value<ColorPickerValueConverter.PickedColor>("layoutSettingsColourPicker") : null;
var colorLabel = backgroundColour?.Label;
var colorShades = hasSettings ? Model.Settings.Value<decimal>("layoutSettingsColourShades") : (decimal?)null;
var backgroundImage = hasSettings ? Model.Settings.Value<Umbraco.Cms.Core.Models.MediaWithCrops>("layoutSettingsBackgroundImagePicker") : null;
}
@{
string styleAttribute = "";
if (hasSettings && backgroundColour != null)
{
styleAttribute = $"background-color: var({colorLabel}";
if (colorShades.HasValue)
{
styleAttribute += $"-{colorShades});";
}
}
else if (backgroundImage != null)
{
styleAttribute = $"background-image: url({backgroundImage.MediaUrl()});";
}
}
<div class="layout py-3" data-bgimage="@backgroundImage.MediaUrl()" style="@styleAttribute" data-block-alias="@Model.Content.ContentType.Alias">