本功能在wordpress 3.3版下可正常使用,其他版本是否可以使用本功能暂时未知。
通过在当前主题的functions.php中加入以下函数,即可非常方便的在博客中显示指定的网页截图,省去了上传等步骤。
打开当前主题的functions.php,加入以下代码:
function wps_screenshot($atts, $content = null) {
extract(shortcode_atts(array(
"screenshot" => 'http://s.wordpress.com/mshots/v1/',
"url" => 'http://',
"alt" => 'screenshot',
"width" => '400',
"height" => '300'
), $atts));
return $screen = '<img src="' . $screenshot . '' . urlencode($url) . '?w=' . $width . '&h=' . $height . '" alt="' . $alt . '"/>';
}
add_shortcode("screenshot", "wps_screenshot");
发布文章时,使用以下代码实现在线网页截图的功能:
[screenshot url=http://www.csdn.net alt="wordpress code snippets for your blog" width="200" height="200"]