Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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).