How to customize a permalink (URL) structure?

The GUID field is not a URL and should never be used for that purpose. It’s a unique identifier that happens to look like a URL, but it should never be trusted as such.

WordPress has a number of functions for retreiving attachment URLs and files:

get_children

get_attached_media

the_attachment_link

get_attachment_link

wp_get_attachment_link

wp_get_attachment_image

wp_get_attachment_image_src

wp_get_attachment_url

wp_get_attachment_thumb_file

wp_get_attachment_thumb_url

wp_get_attachment_metadata

The function wp_get_attachment_image is probably what you’re looking for in this case.