Code for view, and module name in path besides node id
In that same block of code, can do an arg() check. 

$node = menu_get_object(); 
$menu_image = 'arrow_home.png'; 
if (!empty($node)) { 
  $images = array(2 =&gt; 'arrow_home.png', 3 =&gt; 'arrow_formazione.png', 4 =&gt; 'arrow_workshop.png', 5 =&gt; 'arrow_raccontabito.png'); 
  $menu_image = isset($images[$node-&gt;nid]) ? $images[$node-&gt;nid] : $menu_image; 
} 
if (arg(1) == 'gallery') {
  $menu_image = 'arrow_gallery.png';
} 
elseif (arg(1) == 'contact') { 
  $menu_image = 'arrow_contact.png';
}


Note: This will only work as long as the URL structure stays the same.

Also, this code depends on where you are preprocessing the image. If you are using template_preprocess_node() the above will not work because those two pages, even though they are located at the node path, are not nodes.