Custom Post Type with image gallery

Custom Post Types can have image attachments like other post types. A simple way to display them is via the gallery shortcode. There are several plugins out there to enhance the gallery output, or you can also display attachments in a single post yourself via the API, for example with get_posts.

The only requirement you won’t get out of the box is deletion of attachments when the parent post is deleted, as images can be used in other posts so that could potentially break things. If that’s not a concern, you can delete attachments on post delete with a bit of code hooked to deletion:

function delete_post_children($post_id) {
    global $wpdb;

    $ids = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE post_parent = $post_id AND post_type="attachment"");

    foreach ( $ids as $id )
        wp_delete_attachment($id);
}
add_action('delete_post', 'delete_post_children');

taken from http://core.trac.wordpress.org/ticket/12108