You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

mime-icons

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mime-icons

Pick an icon for specific media resource by MIME

0.0.5
latest
Source
npmnpm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

MIME icons

Give an icon to a web resource file by Content-Type or url subfix.

Usage

npm install mime-icons

First, MUST copy icons folder to your project's public files path.

Now, import module, with getIconName function, you will get the target icon name. The function get 2 optional parameters:

parameterfrom
contentTypeHTTP response header's Content-Type
urlresource url

example:

import mime from "mime-icons";

const icon = mime.getIconName({
  contentType: "text/html",
  url: "http://xxx.com/index.html",
});

const imagePath = env.PUBLIC_PATH + "/icons/" + icon;

Example

git clone https://github.com/DeronW/mime-icons
cd mime-icons/demo
npm i
npm run dev
# open http://localhost:5173

Resources

Thanks to apache for content-type and file extensions mapping, and vscode-icons for extensions icons.

customize

Some files has common extension, use common use case overwrite it, such as js, css, html and soon.

Keywords

mime

FAQs

Package last updated on 30 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts