Skip to content

Instantly share code, notes, and snippets.

@lydonchandra
Created August 29, 2019 09:58
Show Gist options
  • Save lydonchandra/b72d95f541c52653673f576c23a46332 to your computer and use it in GitHub Desktop.
Save lydonchandra/b72d95f541c52653673f576c23a46332 to your computer and use it in GitHub Desktop.
console.image.js - display image in console.log
console.image = function(url, sizePercent = 100, message) {
var image = new window.Image();
image.onload = function() {
var style = [
'font-size: 1px;',
'padding: ' + this.height/100*sizePercent + 'px ' + this.width/100*sizePercent + 'px;',
'background: url('+ url +') no-repeat;',
'background-size: contain;',
'message: ' + message + ';'
].join(' ');
console.log('%c ', style);
console.log(message)
};
image.onclick = function() {
}
image.src = url;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment