updated   : April 22, 2013
we now have 608 snippets

Display screenshot of any website using shortcode

wordpress snippet

Adding the first snippet to the functions.php of your wordpress theme will let you use the bellow shortcode to display a screenshot of any website.

snippet :  PHPcopy
function wps_screenshot($atts, $content = null) {
        extract(shortcode_atts(array(
			"screenshot" => 'http://s.wordpress.com/mshots/v1/',
			"url" => 'http://',
			"alt" => 'screenshot',
			"width" => '400',
			"height" => '300'
        ), $atts));
		return $screen = '<img src="' . $screenshot . '' . urlencode($url) . '?w=' . $width . '&h=' . $height . '" alt="' . $alt . '"/>';
}
add_shortcode("screenshot", "wps_screenshot");
snippet :  SHORTCODEcopy
[screenshot url="http://wpsnipp.com" alt="wordpress code snippets for your blog" width="200" height="200"]
  • http://wpsnipp.com Kevin Chard

    This may be true but if you preview your post before hand that should not be a big problem.

  • jamie

    The main downfall is not utilizing the featured image.

    • http://wpsnipp.com Kevin Chard

      Hi Jamie, You could do this with the featured image but would require you do create screenshots of every site. This way you only need to add the url of any site to get a screenshot.