title: How to close FancyBox when popup image with link is clicked?
body: <p>I have a FancyBox, that opens a link when clicked on the popped up image:  </p>
  
  <pre><code>$(".fancybox").fancybox({
      afterShow: function () {
          $(".fancybox-image").wrap("&lt;a href='"+$(this.element).attr('name')+"' target='_blank' /&gt;");
      }
  });
  </code></pre>
  
  <p>Now, I'd like to close the FancyBox when the photo is clicked so I add <code>closeClick</code>:</p>
  
  <pre><code>$(".fancybox").fancybox({
      closeClick: true,
      afterShow: function () {
          $(".fancybox-image").wrap("&lt;a href='"+$(this.element).attr('name')+"' target='_blank' /&gt;");
      }
  });
  </code></pre>
  
  <p>This doesn't work. The link opens fine, but the FancyBox doesn't close. </p>
  
  <p>If I remove <code>aftershow</code> FancyBox closes just fine. </p>
  
  <p>So how can both be achieved with a click? </p>