$id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID', 'posts_per_page' => $max_images, ) ); foreach ( $query->get_posts() as $attachment ) { if ( ! in_array( $attachment->ID, $image_ids ) ) { $image_ids[] = $attachment->ID; } } // get URLs for each image foreach ( $image_ids as $id ) { $thumbnail = wp_get_attachment_image_src( $id, 'full' ); $mimetype = get_post_mime_type( $id ); if ( $thumbnail ) { $images[] = array( 'url' => $thumbnail[0], 'type' => $mimetype ); } } return $images; }