dmhendricks/file-icon-vectors

Default icon

Opened this issue · 3 comments

if an icon doesn't exist is there a way to show a default one for an extension not recognized?

kind regards

Same question! You mention it briefly in readme but I need an example.

For anyone still wondering, the readme pretty much tells you what you can do, each of the sets has a catalog: https://github.com/dmhendricks/file-icon-vectors/blob/master/dist/icons/high-contrast/catalog.json said catalog contains an array of all file-extensions, you have multiple ways of including it:

  • webrequest a githack'd version of the catalog you want
  • hard-code copy paste the catalog array of your icon set(s) into your code
  • embed it via external script tag, but then you'd have to give the script tag a unique identifier in the DOM to be able to access the contents and flush them into a variable

either way you choose, you can then simply check if the catalog array contains the file extension you are requesting, if not, fallback to a default e.g. the txt svg-icon is pretty universal.

to a default

FWIW, the set does include the default icon, default.svg