Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/paramsiddharth/imaginator
Converts each image tag to use data URIs in an HTML document.
https://github.com/paramsiddharth/imaginator
Last synced: about 1 month ago
JSON representation
Converts each image tag to use data URIs in an HTML document.
- Host: GitHub
- URL: https://github.com/paramsiddharth/imaginator
- Owner: paramsiddharth
- Created: 2020-10-02T02:07:28.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2020-10-06T04:06:50.000Z (about 4 years ago)
- Last Synced: 2024-05-22T20:20:59.728Z (7 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Imaginator
An Express middleware that converts image tags to use data URIs instead of image files an HTML document.## Installation
```
> npm install --save imaginator
```## Usage
``` javascript
const express = require('express');
const path = require('path');
const imaginator = require('imaginator');const app = express();
app.use(imaginator(path.join(__dirname, 'public'), 'img.datauri'));
app.use(express.static(path.join(__dirname, 'public')));app.listen(3000);
```**`imaginator(publicDirectory, selector = 'img')`**
- `publicDirectory` : The path to the directory where the hosted public files (including the images) are stored. In most cases, it should be set to `path.join(__dirname, 'public')`.
- _`selector`_ : The CSS-style selector for the tags to be affected. Its default value is `'img'` i. e. All `img` tags will be affected.## Example
`index.html` before applying Imaginator:
``` html
Hi
Hello world!
```
`index.html` after applying Imaginator:
``` html
Hi
Hello world!
```
Made with ❤ by [Param](http://www.paramsid.com).