Created
August 29, 2019 09:58
-
-
Save lydonchandra/b72d95f541c52653673f576c23a46332 to your computer and use it in GitHub Desktop.
console.image.js - display image in console.log
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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