Nowadays a lot of webmasters are looking for a website snapshot tool in order to make data presentation more attractive to their visitors. Making website thumbnail manually is a routine process, needs much time, and for big sites can lead to hiring someone dedicated mostly to making website thumbnails for their needs.
Today, I’m going to show you how to create shortcode in order to easily display snapshot of a specific website.
The first step is to create the shortcode. To do so, simply paste the code below into your functions.php file.
function wpr_snap($atts, $content = null) {
extract(shortcode_atts(array(
"snap" => 'http://s.wordpress.com/mshots/v1/',
"url" => 'http://www.catswhocode.com',
"alt" => 'My image',
"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");
Once done, you can use the snap shortcode, as shown in the following example:
[snap url="http://www.catswhocode.com" alt="My description" w="400" h="300"]
Please note that the height parameter can be omitted.
Thanks to Valentin Brandt for the cool tip!
