actually, what you have in your code here, either of them, should work if the image is added to the category.
$foto = get_field( 'foto', $queried_object );
$foto = get_field( 'foto', $taxonomy . '_' . $term_id );
but this will be false since it’s not using one of the two values for post ID from above
if( get_field('foto') ) {
pick one of the first two and use it for all acf calls