About year ago i created a plugin to enhance console logs, main idea was to print images in console, so for example You could add some icons or glyphs.
It was working pr
I've been searching for a while for one that can print out the whole image without cutting it, and make it resizeable, and I came up with basically this:
console.image = function(url, size = 100) {
var image = new Image();
image.onload = function() {
var style = [
'font-size: 1px;',
'padding: ' + this.height/100*size + 'px ' + this.width/100*size + 'px;',
'background: url('+ url +') no-repeat;',
'background-size: contain;'
].join(' ');
console.log('%c ', style);
};
image.src = url;
};
and then just use console.image(URL[, size]); to print out the image.
The URL needs to be a valid URL and the size is basically percentage, with 100 being the default value. It can get shrunk down if the value is lower than 100, and expanded if the value is higher than 100.