Вот решение на PHP, оно лучше
<?php
$structure = new Structure();
// Получаем данные о текущей странице
$structure_parent_id = CURRENT_STRUCTURE_ID;
$structure_propertys_id = 14; // ID свойства с картинкой
$queue = array();
while ($structure_parent_id != 0) {
$row_structure = $structure->GetStructureItem($structure_parent_id);
$row = $structure->GetStructurePropertyValue($structure_parent_id, $structure_propertys_id);
$structure_parent_id = $row_structure['structure_parent_id'];
if($row['structure_propertys_values_file'] != NULL) {
$queue[] = $row;
}
}
if(count($queue) > 0) {
$queue = array_reverse($queue);
$last = array_pop($queue);
$filename = $last['structure_propertys_values_file'];
$dir = $structure->GetStructureItemDir($last['structure_id']);
$bilbordpath = '/'.$dir.$filename;
} else {
$bilbordpath = false;
}
if($bilbordpath != false) {
echo '<img src="'.$bilbordpath.'" alt="" width="960" height="200">';
} else {
echo 'default';
}
?>