title: get_attachment from functions.php
body: <p>I'm trying to open an image with a lightbox (colorbox) and when it did, have a button that opens a link to it's <em>attachment-page</em>.</p>
  
  <p>I made the attribute <code>data-att=""</code> were the link to the attachment-page should get.</p>
  
  <p>Here is what i have in <strong>functions.php</strong> right now:</p>
  
  <pre><code>add_filter('the_content', 'add_colorbox');
    function add_colorbox($content) {
      global $post;
      $att_url = wp_get_attachment_link($id);
      $pattern ="/&lt;a(.*?)href=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")(.*?)&gt;/i";
      $replacement = '&lt;a$1href=$2$3.$4$5 class="fotos" data-att="'. $att_url .'" title="'.$post-&gt;post_title.'"$6&gt;';
      $content = preg_replace($pattern, $replacement, $content);
    return $content; 
    }
  </code></pre>
  
  <p>So with <code>$att_url = get_attachment_link($id);</code> im trying to get the attachment link and pass it to the <code>data-att="..."</code> with no luck yet...</p>