Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

So I've got a bunch of content with images inserted into them. The users inserting content have done the default option of linking to the attachment page which isn't great. I've altered the

image_default_link_type
setting to make this link to the file by default now.

But I'd like to use a light box or something to display images on the site, which requires the to go to the image file, not the attachment page. Whilst I can make this work for images added since the default was changed, I was wondering if there was any solution that could make this change for me that was not going through and altering the content of each post?

TIA, Dan.

share|improve this question

1 Answer 1

If you are never going to use the attachment page, then you can simply change the HTTP header ( a php function ) of attachment page to the image file.

Example -

header('Location: ' . wp_get_attachment_url() );

Note - Call it inside WordPress loop.

share|improve this answer
    
It's that simple :O –  gravy Aug 21 '12 at 21:10
    
Just a thought, should work. –  amit Aug 21 '12 at 21:23
    
Because this will not alter the links on the page, it's more of an hack (a nice one) and not a real solution because it doesn't change the links on the page. Links will still go to the attachment page. In some scenarios it would be better to change the links on the page. e.g. if you want to run Lightbox / Colorbox to preview images. –  grm Feb 10 '13 at 3:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.