Skip to content

Instantly share code, notes, and snippets.

@ouweiya
Created September 20, 2018 07:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ouweiya/85419d25a6efcf8d9580ee1cc0b2d041 to your computer and use it in GitHub Desktop.
Save ouweiya/85419d25a6efcf8d9580ee1cc0b2d041 to your computer and use it in GitHub Desktop.
Chrome console print picture 2018
(function(c) {
c.image = function(t) {
var img = new Image;
img.src = t;
img.onload = function (){
var style = [
"padding:" + Math.floor(img.height / 2) + "px " + Math.floor(img.width / 2)+ "px",
"background: url("+ encodeURI(t) +")",
"color: transparent",
"font-size:0",
].join(';');
console.log('%c.', style);
}
}
})(console);
console.image("https://github.com/ouweiya/ouweiya.github.io/blob/master/my-blog/chrome1.png?raw=true");
@ouweiya
Copy link
Author

ouweiya commented Sep 20, 2018

c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment