This function supports a number of our image gallery functions. The first is published on this page. There's also an article on our blog, "Find all Images (Except the Featured Image) Attached to a WordPress Post or Page", that discuses the WordPress functions in a little more depth.
Copy and paste the WordPress function into your theme's
functions.php file or, if you sensibly have one installed, your custom functions plugin.