为你的wordpress添加显示网站截图功能

本功能在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"]


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值