From 2026271777f78273ba753130dab8f6e3ac94f949 Mon Sep 17 00:00:00 2001 From: Antonytm Date: Mon, 25 Mar 2024 13:49:19 +0200 Subject: [PATCH] #135 Add null check on HttpContext.Current for Coveo compatibility --- src/Dianoga/NextGenFormats/MediaProvider.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Dianoga/NextGenFormats/MediaProvider.cs b/src/Dianoga/NextGenFormats/MediaProvider.cs index be91a8d..56ede99 100644 --- a/src/Dianoga/NextGenFormats/MediaProvider.cs +++ b/src/Dianoga/NextGenFormats/MediaProvider.cs @@ -31,8 +31,11 @@ public override string GetMediaUrl(MediaItem item, Sitecore.Links.UrlBuilders.Me protected virtual string GetMediaUrl(MediaItem item, string url) { + var helpers = new Helpers(); - if (item.MimeType.StartsWith("image") && !url.Contains("extension")) + if (HttpContext.Current != null + && item.MimeType.StartsWith("image") + && !url.Contains("extension")) { var extensions = helpers.GetSupportedFormats(new HttpContextWrapper(HttpContext.Current)); if (!string.IsNullOrEmpty(extensions))