Back to Blog
WordPress Feb 07, 2012

Create WordPress Shortcode to display Websites Screenshot Thumbnails

Eran Shor

Eran Shor

We develop smart plugins, apps, solutions and integrations for WooCommerce and Shopify.

I was searching for a way to show screenshot preview of sites in WordPress instead of uploading images, this way, if a site changes, It will show the updated version, extremly helpful when you have a directory that needs to be updated (less maintanance…)

Example:

function wpr_snap($atts, $content = null) {
	extract(shortcode_atts(array(
		"snap" => 'http://s.wordpress.com/mshots/v1/',
		"url" => 'http://www.internoetics.com',
		"alt" => 'Image text',
		"w" => '400', // width
		"h" => '300' // height
	), $atts));

	$img = '<img src="' . $snap . '' . urlencode($url) . '?w=' . $w . '&h=' . $h . '" alt="' . $alt . '">';
	return $img;
}
add_shortcode("snap", "wpr_snap");

Than add this to your theme code or to any post/page

For more detailed information check out: