隨機圖片 banner

Saturday, June 4th, 2005 at 1:45 am

參照 Matt 的作法,把 code 存成 PHP 檔 (ex: random.php)之後,與圖片放入相同的資料夾中即可。

如果想隨機替換 WordPress 的 header 圖片,以 Kubrick theme 為例,修改 theme 底下的 header.php,將

URL("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickheader.jpg")

改成

URL("<?php bloginfo('stylesheet_directory'); ?>/images/banner/random.php")

再使用符合尺寸的圖片 (jpg、PNG、gif),或是 Digital Westex Image Gallery 的圖片,就能隨機顯示 banner 資料夾裡的圖片了。

要注意的是主機流量會增加不少,所以圖片的容量最好不要太大,當然如果機器是自己的就沒差啦 XD

Posted in 網頁調教
by hsuyo