【转】把博客背景设置为bing美图

瞎折腾 483 views 1 min read


嘛…在家闲着没事干,乱折腾博客。对于博客背景有选择恐惧症,所以就在网上找了教程,写文存档。

其实很简单:
1.首先在Wordpress主题目录下建立bing.php
//bing每日一图 $str=file_get_contents('http://cn.bing.com/HPImageArchive.aspx?idx=0&n=1'); if(preg_match("/(.+?)<\/url>/ies",$str,$matches)){ $imgurl='http://cn.bing.com'.$matches[1]; } if($imgurl){ header('Content-Type: image/JPEG'); @ob_end_clean(); @readfile($imgurl); @flush (); @ob_flush(); exit (); } else { exit('error'); } ?>\

  1. 在Wordpress后台编辑css,把bg引用的链接改为background-image: url("bing.php")即可

转自:这里

Alpaca
Alpaca author
Be a better man · 记录学习与折腾的每一天