placeholder.js-可在浏览器端生成占位图片的js插件 A Client-side library generate image placeholders
1. Programmatic use API to process image: placeholder.getData(opts)
document.getElementById('img_holder').setAttribute('src', window.placeholder.getData(opts));
2. Image onerror event
onerror="this.src=placeholder.getData({size: '256x128', text: 'Image 404'})"
3. Use image config attribute.
<img class="placeholder">
<img options="size=256x128&text=Hello!" class="placeholder">
<img options="size=256x128&text=Hello!&bgcolor=#ccc&color=#969696&fstyle=oblique&fweight=bold&fsize=40&ffamily=consolas" class="placeholder">