Skip to content

Commit

Permalink
Merge pull request #10 from YongX/master
Browse files Browse the repository at this point in the history
fix canWebp bug
  • Loading branch information
banrikun authored Sep 19, 2018
2 parents e172064 + 31409db commit cd4eb08
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.cache
.DS_Store
node_modules
.idea
5 changes: 1 addition & 4 deletions src/base.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
const VueImg = Object.create(null)

// Check webP support
VueImg.canWebp = false
const img = new Image()
img.onload = () => { VueImg.canWebp = true }
img.src = 'data:image/webp;base64,UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAsAAAABBxAREYiI/gcAAABWUDggGAAAADABAJ0BKgEAAQABABwlpAADcAD+/gbQAA=='
VueImg.canWebp = !![].map && document.createElement('canvas').toDataURL('image/webp').indexOf('data:image/webp') === 0;

// Default cdn prefix
const protocol = location.protocol === 'https:' ? 'https://' : 'http://'
Expand Down

0 comments on commit cd4eb08

Please sign in to comment.