I want to check if a file exists in any skin and thus the result of $block->getSkinUrl('foo.png')
points to a valid URL.
How can I accomplish that?
This seems to work
/**
* Get skin URL of image in language specific version - fall back to English (en)
* @param $ressource string - %s for language
*/
public function getSkinUrlFallback($resource)
{
$file = sprintf($resource, $this->getLang());
$skinBase = Mage::getBaseUrl('skin', Mage::app()->getStore()->isCurrentlySecure());
$skinUrl = $this->getSkinUrl($file);
$path = str_replace($skinBase, '', $skinUrl);
if (file_exists(Mage::getBaseDir('skin') . DS . $path)) {
return $skinUrl;
} else {
$file = sprintf($resource, 'en');
return $this->getSkinUrl($file);
}
}
glob('skin/fronend/*/*/foo.png')
and see if any of the results match one of the themes.