Skip to content

Instantly share code, notes, and snippets.

@ovizii
Last active July 13, 2020 18:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ovizii/381ec8632724a9e8985c to your computer and use it in GitHub Desktop.
Save ovizii/381ec8632724a9e8985c to your computer and use it in GitHub Desktop.
Remote site snapshot using Wordpress API shortcode
function wpr_snap($atts, $content = null) {
extract(shortcode_atts(array(
"snap" => 'http://s.wordpress.com/mshots/v1/',
"url" => 'http://www.sagive.co.il',
"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");
//how to use: [snap url="http://www.example.com" alt="Cool Site!" w="300px" h="200px"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment