Skip to content

Commit

Permalink
kamsar#135 Add null check on HttpContext.Current for Coveo compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonytm committed Mar 25, 2024
1 parent c633b58 commit 2026271
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Dianoga/NextGenFormats/MediaProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 2026271

Please sign in to comment.