phpを使用してフォルダー内のファイルを開いて一覧表示しましたが、「暗い」背景フォルダーからの場合は白いロゴが表示され、 「明るい」背景フォルダには黒いロゴが表示されます。
<?php
//path to directory to open
$directory = "backgrounds/dark";
$dir_handle = @opendir($directory) or die("Unable to open folder");
while(false !== ($file = readdir($dir_handle)))
{
if($file != '.' && $file != '..')
{
echo "{image : 'http://occa-art.com/backgrounds/dark/".$file."'}, ";
}
}
closedir($dir_handle);
?>
{image:'http://'}形式が使用されるのは、画像がスーパーサイズの背景スクリプト内にリストされているためです。
- -編集 - -
たぶん、背景画像がどのフォルダからのものであるかを決定するために、このようなもの(テストされていない):
<?php
$doc = new DOMDocument();
$doc->loadHTML($htmlAsString);
$xpath = new DOMXPath($doc);
$nodeList = $xpath->query('//img[@class="bg"]/@src');
for ($i = 0; $i < $nodeList->length; $i++) {
# Xpath query for attributes gives a NodeList containing DOMAttr objects.
# http://php.net/manual/en/class.domattr.php
echo $nodeList->item($i)->value . "<br/>\n";
}
$bg_url = $nodeList->item($i)->value; // not sure about this?
$parent = dirname("$bg_url");
if ($parent == 'dark') { ?>
<img src="<?php bloginfo('template_url'); ?>/images/OCCAIndexHeaderwhite.png" alt="OCCA logo" />
<?php } else { ?>
<img src="<?php bloginfo('template_url'); ?>/images/OCCAIndexHeaderblack.png" alt="OCCA logo" />
<?php } ?>