Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.0.2 - add svg support #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ var contentTypes = {
".gif": "image/gif",
".jpg": "image/jpeg",
".jpeg": "image/jpeg",
".svg": "image/svg+xml",
".bmp": "image/bmp",
".webp": "image/webp"
}

module.exports = function(html, base) {
base = base || process.cwd()

var dom = cheerio.load(String(html))
inlineImages(dom)

return new Buffer(dom.html({decodeEntities: false}))

function inlineImages(dom) {
var styles = [];
dom('img').each(function(idx, el) {
Expand All @@ -35,7 +36,7 @@ module.exports = function(html, base) {
}
})
}

function isLocal(href) {
return href && !url.parse(href).hostname;
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "inline-images",
"version": "1.0.1",
"version": "1.0.2",
"main": "index.js",
"bin": {
"inline-images": "cli.js"
Expand All @@ -9,7 +9,7 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"cheerio": "cheeriojs/cheerio"
"cheerio": "1.0.0-rc.10"
},
"author": "max ogden",
"license": "BSD",
Expand Down
4 changes: 3 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# inline-images

transforms html and replaces img tags with data URIs, e.g.`<img src="foo.png">` tags with `<img src="data:">`
Transforms html and replaces img tags with data URIs, e.g. `<img src="foo.png">` tags with `<img src="data:">`.

Supports: PNG, GIF, JPG, SVG, BMP, WEBP

```
npm install inline-images -g
Expand Down