Last active
July 13, 2020 18:17
-
-
Save ovizii/381ec8632724a9e8985c to your computer and use it in GitHub Desktop.
Remote site snapshot using Wordpress API shortcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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