-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
355ebe8
commit 7b3c4c3
Showing
3 changed files
with
8 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,19 @@ | ||
using Grand.Infrastructure; | ||
using Grand.Infrastructure.Plugins; | ||
using Grand.Infrastructure.Plugins; | ||
|
||
namespace Grand.Web.Admin.Extensions; | ||
|
||
public static class PluginExtensions | ||
{ | ||
public static string GetLogoUrl(this PluginInfo pluginDescriptor, IWorkContext workContext) | ||
public static string GetLogoUrl(this PluginInfo pluginDescriptor, string url) | ||
{ | ||
ArgumentNullException.ThrowIfNull(pluginDescriptor); | ||
ArgumentNullException.ThrowIfNull(workContext); | ||
|
||
if (pluginDescriptor.OriginalAssemblyFile?.Directory == null) return null; | ||
var storeLocation = workContext.CurrentHost.Url.TrimEnd('/'); | ||
var storeLocation = url.TrimEnd('/'); | ||
var pluginDirectory = pluginDescriptor.OriginalAssemblyFile.Directory; | ||
var logoPluginJpg = Path.Combine(pluginDirectory.FullName, "logo.jpg"); | ||
if (File.Exists(logoPluginJpg)) | ||
return $"{storeLocation}/{pluginDirectory.Parent.Name}/{pluginDirectory.Name}/logo.jpg"; | ||
return $"{storeLocation}/{pluginDirectory.Parent?.Name}/{pluginDirectory.Name}/logo.jpg"; | ||
var logoPluginPng = Path.Combine(pluginDirectory.FullName, "logo.png"); | ||
if (File.Exists(logoPluginPng)) | ||
return $"{storeLocation}/{pluginDirectory.Parent.Name}/{pluginDirectory.Name}/logo.png"; | ||
return null; | ||
|
||
return File.Exists(logoPluginPng) ? $"{storeLocation}/{pluginDirectory.Parent?.Name}/{pluginDirectory.Name}/logo.png" : null; | ||
} | ||
} |