Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Force images added to post to point to the file itself WordPress


For a blog, many authors keep forgetting to link to the file instead of an attachment when adding images to their post. I'm using the Lightbox 2 plugin and want all images in a post to open in a gallery lightwindow. However, since the users are linking to an attachment the "automate' isn't working. Is there a function to make all images point to the original and would this work with Lightbox 2?

Thanks in advance!

Answers (2)


Julio Potier answers:

I'm the author of lightbox 3, don't use lightbox 2 anymore.
There is a CSRF & XSS vulnerabilities inside.

I invite you to post your demand on my post on my blog.

Old plugin :
New plugin :

See you

ps : your "problem" exists in my 3.0 too i think :]


Richard M. answers:

There is a hidden options page in WordPress under http://yoursite/wp-admin/options.php
On that endless list of undocumented options you can set a value for "image_default_link_type". You may want to set it to "file" (without the quotes) to link all your images by default to the original image.

Caroline Keim comments:

But this is just from here on out, correct? There's over 400 posts that need fixing.

Any suggestions?

Richard M. comments:

Try adding this to your functions.php file in your theme:

<? update_option('image_default_link_type' , 'file'); ?>

Caroline Keim comments:

Unfortunately doesn't swap out the old ones.

Richard M. comments:

One moment - going to test something

Richard M. comments:

You can update your database - if you do a search for attachment you'll find that your wp_posts table has images set as <a rel="attachment - you can find and replace the anchor tags

Caroline Keim comments:

What would the query look like? I think that's probably the best way to do it. Thanks!

Caroline Keim comments:

I realized a query may not work in the database since all images will point towards themselves. Thoughts?