Using Captions With The Attached Image

/ Wordpress / by Paul Robinson / 0 comments
This post was published back on November 26, 2009 and may be outdated. Please use caution when following older tutorials or using older code. After reading be sure to check for newer procedures or updates to code.

How To Add A Caption When Using The Attached ImageOk so a few people have asked me if it would be possible to add captions into my plugin The Attached Image. The answer, probably yes, however it’s a little outside it’s scope & it can’t do everything people ask for or it will turn into a bloated plugin that uses massive amounts of memory. So instead I’ve come up with a simple tutorial on how to do it manually. Yes it’s harder, but unfortunately it’s the only viable way to do it without bloating TAI.

Over on the right is what the captions could look like if you want to make them look nearly indistinguishable from the ones WordPress normally makes. I do give the CSS & HTML to do that further down however I’m not a master of CSS so sorry if there are any mistakes.

Anyway here we go. Basically we are going to use WordPress’ custom fields to add a caption. CSS styling isn’t my best point so I’ll leave that to you. Here is the code you need to add The Attached Image, plus a caption:

If you have the options set for The Attached Image in the admin you won’t need anything in the quotes, just leave 'img_size=thumb' out & it will work fine. Finally add your text in the value field & imageCaption in the key field and hit update. That’s it done, you can even include HTML. 🙂

Put together with some HTML your code could look like this:

With some basic CSS that tries to imitate WordPress’ normal caption system:

I hope that helps anyone looking to add a caption system along with my plugin The Attached Image. Let me know if you run in to any problems & I’ll help as much as I can. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

I'll keep your WordPress site up-to-date and working to its best.

Find out more