Create WordPress Shortcode to display Websites Screenshot Thumbnails

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:

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.