Skip to content

aqzhyi/html-img-digger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

html-img-digger

Usage

Basic

import digger from 'html-img-digger'

let tpl = '<div><img src="http://placehold.it/350x150"></div>'
let images = digger.dig(tpl)

images

[
  {
    url: 'http://placehold.it/350x150',
    alt: '',
  },
]

Download remote images (size digs, but slower)

let tpl = '<div><img src="http://placehold.it/350x150"></div>'
let images = digger.dig(tpl, { remote: true })

images

[
  {
    url: 'http://placehold.it/350x150',
    alt: '',
    width: 350,
    height: 150,
  },
]

Development

npm run dev

Test

npm test
dig()
  ✓ 從傳入的 htmlString 中,採集出 img 物件們
  ✓ 允許遠端採集圖片寬與高(using http request) (651ms)

About

Img elements as plain-object extract from html-string.

Resources

Stars

Watchers

Forks

Packages

No packages published