Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for local hosted plugin logo files (png only) #18811

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

developer-labs-lcc
Copy link

@developer-labs-lcc developer-labs-lcc commented Jan 24, 2025

Added support for local hosted logo files (png only).

Checklist before requesting a review

Please delete options that are not relevant.

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.
  • This change requires a documentation update.

Description

  • It fixes # (issue number, if applicable)
  • Here is a brief description of what this PR does

Screenshots (if appropriate):

Added support for local hosted logo files (png only).
src/Glpi/Marketplace/View.php Outdated Show resolved Hide resolved
@cedric-anne cedric-anne changed the title Update View.php Added support for local hosted plugin logo files (png only) Jan 27, 2025
Comment on lines 283 to 284
// found a logo from online resource?
if (isset($apidata['logo_url']) && strpos(strtolower($apidata['logo_url']), '.png') !== false) return $apidata['logo_url'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, it would even be preferable to serve the local icon first. Some GLPI administrators complains about the fact that the marketplace view requires access to remote contents.

{

// found a logo from online resource?
if (isset($apidata['logo_url']) && strpos(strtolower($apidata['logo_url']), '.png') !== false) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why restricting on PNG files only? As far as I see, there is no such existing restriction; this would break existing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(same remarks for other png extension checks)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation does not mention other file formats than png:
https://glpi-developer-documentation.readthedocs.io/en/master/plugins/guidelines.html#directories-structure

But I can remove the check for the online logo url - no problem.

For the local checks it is too much work to check for other file formats and I guess it is not really necessary. Gifs are annoying and who needs a jpg for an plugin icon at all? Maybe webp would be an alternative...

$logo = $pluginDir . $key . '.png';

// logo named as the key found?
if (file_exists($logo) && is_readable($logo)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a check that the file is actually an image I think. Not sure it is a big issue, but should be safer.

The local check is only intended for developing purposes if a plugin is not (yet) published on the marketplace. Otherwise the icon defined in the xml file of the plugin will be used as symbol.

Note: Most plugins in the marketplace uses png files. The plugin "Webhook" uses a svg file instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants