I put this together it is showing the third level yea!! but it clears the second level back to 0 for the cat id
for instance the url --> /images/0.jpg
function osc_item_parent_category_id() {
if ( !View::newInstance()->_exists('item_category') ) {
View::newInstance()->_exportVariableToView('item_category', Category::newInstance()->findByPrimaryKey( osc_item_category_id() ) );
}
$category = View::newInstance()->_get('item_category') ;
$parentCategory = osc_get_category('id', $category['fk_i_parent_id']);
View::newInstance()->_exportVariableToView('id', $parentCategory);
return (int) osc_field($parentCategory, "fk_i_parent_id", "") ;
}