backdrop-contrib / icon_browser

An interface to browse the fonts that are available on a Backdrop site.
GNU General Public License v2.0
1 stars 3 forks source link

Icon Browser doesn't fully support hook_icon_info(). #15

Closed bugfolder closed 2 weeks ago

bugfolder commented 2 weeks ago

The sample code for hook_icon_browser() allows us to pass an empty array for icon SVGs that are in a module's icons subdirectory:

function hook_icon_info() {
  // For icons simply located in a module's "icons" directory, just provide the
  // name of the file (minus ".svg") as the array key. This can be used to
  // override core icons if the name of the icon matches a core one, or provide
  // new ones if the name is unique.
  $icons['my-module-icon1'] = array();

  // <snip>
  return $icons;
}

Which means that we ought to be able to do this in a module with two icons in its icons subdirectory:

/**
 * Implements hook_icon_info().
 */
function icon_browser_test_icon_info() {

  $icons['acorn-fill'] = array(); // Override the core 'acorn-fill' icon
  $icons['test-acorn-fill'] = array(); // Create our own new icon

  return $icons;
}

However, if we do, there are two problems. First, in the Icon Browser, the name of overridden acorn-fill is lost:

image

Second, if we set "Module" as provider, we get two icons with no name:

image

Attached is a small test module that can be used to verify the issue.

icon_browser_test.zip

laryn commented 2 weeks ago

@bugfolder Looks like we filed exactly the same PR. 😆

bugfolder commented 2 weeks ago

At the same time, it appears. Keep whichever one you want.

laryn commented 2 weeks ago

Thanks @bugfolder -- merged!