Yes, absolutely, it is possible.
And here’s an example: Use an action and pass the post’s position in the loop to the action’s callback/function, and let the callback run the conditional and display the image if applicable.
$position = 1; // start at 1
while ( have_posts() ) : the_post();
the_title( '<h3>', '</h3>' );
// Show custom image, if any.
do_action( 'my_loop_custom_image_at_position', $position );
$position++;
endwhile;
Callback: (yes, the conditional could be done in the above loop, but based on your question, I think this is what you’re looking for?)
add_action( 'my_loop_custom_image_at_position', function( $position ){
if ( $position > 2 ) {
echo '<img src="https://placeimg.com/728/90/any" />';
} else { // optional 'else'
echo 'Position is less than 2. So we don\'t show custom image.';
}
} );
PS: In the callback, you can use get_post()
to get the current post’s data.