$post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
// $images is now a object that contains all images (related to current post id) and their information ordered like the gallery interface.
if ( $images ) {
//looping through the images
foreach ( $images as $attachment_id => $attachment ) {
?>