1

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.

1 Answer 1

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.

3
  • It's that simple :O
    – gravy
    Aug 21, 2012 at 21:10
  • Just a thought, should work.
    – Amit Kosti
    Aug 21, 2012 at 21:23
  • 1
    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, 2013 at 3:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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