Error executing template "Designs/Swift-v2/Paragraph/Swift-v2_ProductDefaultImage.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_54383a43615944e3b07b22ca1b7d95cb.<>c__DisplayClass0_0.<ExecuteAsync>b__2(MediaViewModel x) at System.Collections.Generic.List`1.RemoveAll(Predicate`1 match) at CompiledRazorTemplates.Dynamic.RazorEngine_54383a43615944e3b07b22ca1b7d95cb.ExecuteAsync() at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Ecommerce.CustomerExperienceCenter.Favorites 4 5 @{ 6 ProductViewModel product = null; 7 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 8 { 9 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 10 } 11 else if (Pageview.Page.Item["DummyProduct"] != null && Pageview.IsVisualEditorMode) 12 { 13 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 14 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 15 16 if (productList?.Products is object) 17 { 18 product = productList.Products[0]; 19 } 20 } 21 } 22 23 @if (product is object) 24 { 25 string imagePath = product?.DefaultImage?.Value ?? ""; 26 string imagePathUrlEncoded = Dynamicweb.Context.Current.Server.UrlEncode(imagePath); 27 28 string ratio = Model.Item.GetRawValueString("ImageAspectRatio", ""); 29 ratio = ratio != "0" ? ratio : ""; 30 string ratioCssClass = ratio != "" ? " ratio" : ""; 31 string ratioVariable = ratio != "" ? "--bs-aspect-ratio: " + ratio : ""; 32 33 string width = Model.Item.GetRawValueString("Width", "auto"); 34 int smallImageSize = 640; 35 int largeImageSize = width == "auto" ? 1280 : Convert.ToInt32(width); 36 37 string ImageObjectFit = Model.Item.GetRawValueString("ImageObjectFit", "contain"); 38 39 string imagePathXs = "/Admin/Public/GetImage.ashx?width=" + smallImageSize + "&image=" + imagePathUrlEncoded + "&format=webp"; 40 string imagePathS = "/Admin/Public/GetImage.ashx?width=" + largeImageSize + "&image=" + imagePathUrlEncoded + "&format=webp"; 41 string imagePathFallBack = "/Admin/Public/GetImage.ashx?width=" + largeImageSize + "&image=" + imagePathUrlEncoded + "&format=webp"; 42 43 bool showFavoritesSelector = !string.IsNullOrEmpty(Model.Item.GetString("ShowAddToFavorites")) ? Model.Item.GetBoolean("ShowAddToFavorites") : false; 44 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 45 bool anonymousUser = Pageview.User == null; 46 47 var favoriteParameters = new Dictionary<string, object>(); 48 if (!anonymousUser && showFavoritesSelector) 49 { 50 int defaultFavoriteListId = 0; 51 52 IEnumerable<FavoriteList> favoreiteLists = Pageview.User.GetFavoriteLists(); 53 if (favoreiteLists.Count() == 1) 54 { 55 foreach (FavoriteList list in favoreiteLists) 56 { 57 defaultFavoriteListId = list.ListId; 58 } 59 } 60 61 favoriteParameters.Add("ListId", defaultFavoriteListId); 62 } 63 64 MediaViewModel alternativeImage = new MediaViewModel(); 65 if (Model.Item.GetBoolean("ShowAlternativeImageOnHover")) { 66 var selectedImageCategories = Model.Item.GetList("GetAlternativeImageFrom")?.GetRawValue().OfType<string>().ToList(); 67 List<MediaViewModel> allAssetsImages = product.AssetCategories.Where(x => selectedImageCategories.Contains(x.SystemName)).SelectMany(x => x.Assets).ToList(); 68 allAssetsImages.RemoveAll(x => x.Value == product.DefaultImage.Value); 69 alternativeImage = allAssetsImages.FirstOrDefault(); 70 } 71 72 string altImagePathXs = string.Empty; 73 string altImagePathS = string.Empty; 74 75 if (!string.IsNullOrEmpty(alternativeImage?.Value)) 76 { 77 altImagePathXs = "/Admin/Public/GetImage.ashx?width=" + smallImageSize + "&image=" + Dynamicweb.Context.Current.Server.UrlEncode(alternativeImage.Value) + "&format=webp"; 78 altImagePathS = "/Admin/Public/GetImage.ashx?width=" + largeImageSize + "&image=" + Dynamicweb.Context.Current.Server.UrlEncode(alternativeImage.Value) + "&format=webp"; 79 } 80 81 string colorSchemeBorder = !string.IsNullOrWhiteSpace(Model.ColorScheme?.Id) ? "border: 1px solid rgba(0,0,0,0)" : ""; 82 string imageId = "ProductImage_" + product.Id + product.VariantId.Replace(".", "_"); 83 string fullWidth = width == "auto" ? "w-100" : ""; 84 string customWidth = width != "auto" ? "style=\"width: " + width + "px\"" : "style=\"min-width: 60px\""; 85 86 if (!string.IsNullOrEmpty(imagePath)) 87 { 88 <figure class="h-100 @fullWidth position-relative item_@Model.Item.SystemName.ToLower()" @customWidth data-dw-colorscheme="@Model.ColorScheme?.Id"> 89 <div class="ratio" style="@(ratioVariable)"> 90 <div class="d-flex justify-content-center align-items-center"> 91 @if (imagePath.StartsWith("/Files/", StringComparison.OrdinalIgnoreCase)) 92 { 93 <img id="@imageId" 94 srcset=" 95 @imagePathXs @(smallImageSize)w, 96 @imagePathS @(largeImageSize)w" 97 sizes="(max-width: 992px) 50vw, 25vw" 98 src="@imagePathFallBack" 99 @if (Model.Item.GetBoolean("ShowAlternativeImageOnHover") && !string.IsNullOrEmpty(alternativeImage?.Value)) { <text> 100 data-alternative-image=" 101 @altImagePathXs @(smallImageSize)w, 102 @altImagePathS @(largeImageSize)w" 103 onmouseover="swift.Image.swapImage(event)" 104 onmouseout="swift.Image.swapImage(event)" 105 </text> } 106 loading="lazy" 107 decoding="async" 108 class="h-100 w-100" 109 style="object-fit: @ImageObjectFit; @colorSchemeBorder" 110 alt="@product.Name" 111 itemprop="image"> 112 } 113 else 114 { 115 <img id="@imageId" 116 src="/Files/@product.DefaultImage.Value" 117 loading="lazy" 118 class="h-100 w-100" 119 style="object-fit: contain; @colorSchemeBorder" 120 alt="@product.Name" 121 itemprop="image"> 122 } 123 </div> 124 </div> 125 126 @if (!anonymousUser) 127 { 128 if (showFavoritesSelector) 129 { 130 <div class="position-absolute top-0 end-0 my-3" style="z-index: 2"> 131 @RenderPartial("Components/ToggleFavorite.cshtml", product, favoriteParameters) 132 </div> 133 } 134 } 135 </figure> 136 } 137 } 138 else if (Pageview.IsVisualEditorMode) 139 { 140 <div class="alert alert-dark m-0">@Translate("The default image will be shown here, if any")</div> 141 } 142
Dispensers designed for public spaces and high-traffic restrooms
In spaces with heavy foot traffic – whether restrooms, foyers, offices, shops, buffets, or airports – hygiene must be top-notch. Dispensers play a crucial role. Our dispensers are designed to be used. Again and again. Touch-free, efficient, and gentle on both hands and the environment. Built for everyday use. For daily routines. And for all the places where many people pass through – with only a few seconds to ensure a clean and safe experience.
Why choose DAN DRYER dispensers: top 5 reasons
01
MMore hygienic – less contact
Our dispensers are touch-free and activate automatically. This minimizes contact surfaces and reduces the risk of spreading germs – benefiting both users and staff.
02
Better for the environment
Our dispensers provide precise dosing and save on consumption. This applies to both foam soap and disinfectant. With a focus on sustainability and less waste, they are a greener choice.
03
Lower operating costs
Efficient dosing means fewer refills and less usage. At the same time, maintenance is simple, saving time and resources in daily operations.
04
Always ready to use
Our dispensers are reliable and designed for busy environments. They are easy to check, quick to refill, and built to perform all day, every day.
05
Aesthetic and flexible solutions
Choose from many variants and classic RAL colors. Our dispensers can be matched with other products in our ranges to create a cohesive and stylish look in the restroom.
Dispensers designed for busy envireonments. And high hygiene standards
That’s why a dispenser needs to do more than just dispense. It must be both elegant and functional. And it must work – completely automatically, without any effort from the user. With over 40 years of experience in developing hygiene solutions, we know what it takes. Our dispensers are internationally recognized for combining durability with sleek, contemporary design.
LOKI - designed for modern restrooms
Discover LOKI – a sleek and functional product line that has won 9 design awards for its timeless aesthetics and user-friendly design. The series is created to support elegant and practical restroom environments that perform reliably in everyday use.
Get inspired
Find dispensers designed to match your requirements
LOKI touch-free dispenser for soap/disinfectant, white
LOKI touch-free dispenser for disinfectant spray, stainless steel
LOKI touch-free dispenser for disinfectant spray, white
LOKI touch-free dispenser for disinfectant spray, optional RAL classic colours
LOKI touch-free dispenser for disinfectant spray, black
LOKI touch-free dispenser for foam soap/disinfectant, stainless steel
LOKI touch-free dispenser for foam soap/disinfectant, white
LOKI touch-free dispenser for foam soap/disinfectant, black
LOKI touch-free dispenser for foam soap/disinfectant, optional RAL classic colours
Custom solutions
Everything starts with understanding the needs of the building and its users
Every building is unique – and so are its needs. We create hygiene solutions that align with the architecture, the people, and the way the space is used. Working with you, we see the solution through from concept to completion. So everything works – day after day.
Use cases
After a devastating fire, the 160-year-old Hotel Randers underwent a complete renovation and upgrade, including installation of DAN DRYER hand dryers, blending modernity with history.
Customisation was key. Being able to match brand colours and achieve a seamless, harmonious look gave the toilet interiors a truly unique style at Camp Adventure.
The hand dryers and toilet roll holders worked perfectly — just a touch of custom colour and they blend seamlessly. A great, sustainable solution.
Explore our solutions for commercial and public restrooms
BJÖRK
An award-winning product line, recognised for its ergonomics and refined aesthetics. BJÖRK is designed to be used – and noticed.
LOKI
A product line that combines Scandinavian minimalism with maximum functionality. LOKI is award-winning for its floating lightness and cohesive design.
Dan Dryer Railway
Customised hygiene solutions built to meet the toughest industry standards
In the world of train operations, compromise is not an option. With extensive experience working with rolling stock, we fully understand the strict requirements that apply. That’s why we specialise in creating hygiene solutions designed to meet these very technical demands and withstand heavy, continuous use.
Working closely with our clients, we design, test, and tailor every solution to ensure reliable performance on the move.