How to get images only attached from edit post page

I´m using this code to load all images I uploaded via edit post page:

function get_gallery_images(){
    global $wpdb,$post;
        $ids = "";
        $counter = 0;
        $number_of_posts = 12;
        $args = array(
        'post_type' => 'attachment',
        'numberposts' => 12,
        'post_status' => null,
        'orderby' => 'rand',
        'post_parent' => $post->ID
        );
        $attachments = get_posts($args);
        if ($attachments) {
            foreach ($attachments as $attachment) {

                if ($counter != 0) {
                    $ids .= ','.$attachment->ID;
                }
                else {
                    $ids .= $attachment->ID;
                }
                $counter++;
            }
        }
        return $ids;
}

Also this line:

$attachment_ids = get_gallery_images();

And this inside content lines:

echo do_shortcode(''); 

This last line is to show the images are gallery, if you need to show them in another format like slider or carousel this line should be changed according your needs.