How to get rid of the attachment thing on your images
Wordpress Hacks January 5, 2009 1,070 views attachment, hack, images, tutorial
Recently I upgraded this blog to the new WordPress Version (something you should do as well) and I realized that it messed up my galleries. Every image was linked to an own attachment page:

Every time someone clicks the images, there would be a seperate page, instead of a fancyzoom popup. Here is what you can do to set up the gallery function to not use attachment pages for images:
- Go to the
wp-includesfolder and open upmedia.php - In the media.php file search for line 663 (Update: from WordPress 2.8.1 on it is line 684) which says the following
$link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false); - Change this to:
$link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, false, false); - Don’t forget to save it. Then upload the new
media.phpinto yourwp-inlcudesfolder online.
Now your images should be linked to themselves again, like this:

Trackback? If you liked this article, subscribe for more updates.
Fink Tank
Freebies
Games
Hate
Love
WP Hacks


January 6, 2009 at 11:29
Thanks for your comment and happy belated new years to you :)
[Reply]
January 6, 2009 at 09:35
[...] year. I have updated both my blogs to Wordpress 2.7, so that current and easier for me to work How to get rid of the attachment thing on your images – finkaboutit.com 01/05/2009 How to get rid of the attachment thing on your images Posted by Fink [...]
August 20, 2009 at 07:41
Any updates on 2.8.4? Unfortunately, I can’t find anything resembling that coding. I would really love to have this fix, thanks!
[Reply]
Alex Fink Reply:
August 20th, 2009 at 12:58
@Richard Sapien, it definitely is
line 684. You need to change themedia.phpfile located in thewp-includesfolder.[Reply]
Richard Sapien Reply:
August 20th, 2009 at 03:01
@Alex Fink, That’s strange. I couldn’t find it to save my life last night. I ended up using the Cleaner WP Gallery plugin because it helped me do exactly what I wanted (SlimBox 2 implementation), but this will be great for future reference.
I appreciate your help!
[Reply]
Alex Fink Reply:
August 20th, 2009 at 04:00
@Richard Sapien, you’re welcome
August 26, 2009 at 11:23
Hi Alex,
Umm, I couldn’t get this to work on the WP site I’m building.
In actual fact, I’d prefer to be able to style the attachment.php page correctly but can’t for the life of me work out how to do this.
Your code tip seemed like a good simple solution to avoid the issue in the first place but it just doesn’t work, i.e. I click an image and it always takes me to the attachment page.
Any ideas?
regards
Yan
[Reply]
Yan Reply:
August 26th, 2009 at 11:34
Belay the last pipes. I now see that you have to style it up in ‘image.php’.
Phew, that’s better.
Excellent site BTW.
Best
Yan
[Reply]
Alex Fink Reply:
August 26th, 2009 at 12:00
@Yan, as you have seen, the trick works only if you don’t have another specifier like
image.php. That’s a very special theme you got there[Reply]
Yan Reply:
August 27th, 2009 at 04:16
@Alex Fink, fank you for the compliment.
Best
Yan