attachment.php code or tutorial

This is part of the WordPress template system, it allows you to drill down and further customize output based in the template hierarchy, for instance if you want the attachments to have separate functionality/style then your single.php, you simply create attachment.php or go even further with MIME_type.php (like images).

http://codex.wordpress.org/images/1/18/Template_Hierarchy.png

Also you have 4 url options when inserting single images: custom url, file, post or none

enter image description here