Show post tags on attachment page?

This should work to get the parent’s tags.

<?php
global $wp_query;
$attachment_id = $wp_query->post->ID;
$parent_id = get_post_field('post_parent', $attachment_id);
$parent_tags = wp_get_post_tags($parent_id); 
$tag_count = count($parent_tags); // Counting the tags to find know the last one so there is no pipe
$i = 1; // Setting up the count

if ($parent_tags) { ?>
    <div>
    Tagged with:<br />
    <?php foreach ($parent_tags as $tag) {
        if($i < $tag_count) {
            echo '<a href="https://wordpress.stackexchange.com/questions/173304/. get_tag_link($tag->term_id) .">' . $tag->name . '</a> | ';
        } else {
            echo '<a href="https://wordpress.stackexchange.com/questions/173304/. get_tag_link($tag->term_id) .">' . $tag->name . '</a>';  
        }
        $i++;
    } ?>
    </div>
} ?>