How to add Pinterest Button on WordPress Attachment file

How to add Pinterest Button on WordPress Attachment file
See How to Add Pinterest “Pin It” to WordPress for introduction
Codes in article above may work for Posts, but there’s a little tweak for Pinterest Pin It button on attachment.php to work

<div class="pinterest">
<a href="http://pinterest.com/pin/create/button/?url=<?php the_permalink(); ?>&media=<?php echo wp_get_attachment_url(); ?>&description=<?php the_title(); ?> on <?php bloginfo('url'); ?>" class="pin-it-button" count-layout="vertical"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It"></a>
</div>