Get images / media attached to a page by page ID

$all_the_images = get_attached_media( 'image', 31 ); should return any image attachments for a page the ID of 31 if that page has child images. Meaning, there are images that were uploaded and actually attached to that page, not just upload and inserted into that page.

When you use the media uploader (to upload images), from within the Edit screen of the page you’re editing, WP automatically makes those images children of that page. That’s what get_attched_media() returns. If you just use the media uploader to browse the media library and insert images into the content body of the page you’re editing get_attched_media() won’t pull those.