I think the best way is to override catalog image helper (like @stew said). To avoid performance issues we can use raw sql queries to fetch parent's image value:
class Wfs_Catalog_Helper_Image extends Mage_Catalog_Helper_Image
{
public function init(Mage_Catalog_Model_Product $product, $attributeName, $imageFile=null)
{
parent::init($product, $attributeName, $imageFile);
if (!$product->getId() || $imageFile || $product->isConfigurable()) {
return $this;
}
$productImage = $product->getData($attributeName);
if (!$productImage || $productImage == 'no_selection') {
// Get parent product's attribute
$value = $this->getParentProductAttribute($product->getId(), $attributeName);
if ($value) {
$this->_getModel()->setBaseFile($value);
}
}
return $this;
}
public function getParentProductAttribute($productId, $attributeName)
{
$coreResource = Mage::getSingleton('core/resource');
$conn = $coreResource->getConnection('core_read');
$attrId = Mage::getSingleton('eav/config')
->getAttribute(Mage_Catalog_Model_Product::ENTITY, $attributeName)
->getId();
$select = $conn->select()
->from(array('rel' => $coreResource->getTableName('catalog/product_relation')), array())
->join(
array('var' => $coreResource->getTableName('catalog_product_entity_varchar')),
'var.entity_id = rel.parent_id',
array('value')
)
->where('rel.child_id = ?', $productId)
->where('var.attribute_id = ?', $attrId);
return $conn->fetchOne($select);
}
}