28
Jul
2008

Subscribe
Bookmark and Share

wordpressA new feature introduced by WordPress 2.6 is the image caption which automatically adds under every picture in your blog a brief description of your choice. If you read well what I just wrote you should notice the term automatically. This mean that, by default, the aforementioned feature is always on and you don’t have any option to disable it. The code    [ caption ] and [ /caption ] which encloses the IMG, OBJECT or EMBED HTML elements will translate into <div> and </div> CSS attributes to position caption, accordingly.

Here is a brief example:

<a><img /></a>

If you don’t like the idea of having a caption text under your medias (image and videos), here is a little trick to disable and turn it off.

  1. Start your FTP client and gain access to your blog’s root.
  2. Look for this file located in public_html : wp-config.php or this file located in your theme’s folder (public_html/wp-content/themes/yourtheme): functions.php.
  3. Add this code wherever you want in the file: define(’CAPTIONS_OFF’, true);

This little trick will no longer be supported starting from WordPress 2.6.1. As a matter of fact the new WordPress version will have a caption disabling function support via plugin’s filter.

The new caption feature also introduces another important issue which webmasters might face in their themes after upgrading to the new WordPress version. As a matter of fact, WordPress 2.6 adds a DIV code to print the caption title under the picture or image, and to do that it uses a default auto alignment, color, font, and spacing. Because of this, webmasters could notice that the text around an image or a video may not be aligned properly or too close to the picture or video itself. To solve this issue here is a piece of code to add to the theme’s style.css file:

/* Captions */
.aligncenter,
div.aligncenter {
display: block;
margin-left: auto;
margin-right: auto;
}

.wp-caption {
border: 1px solid #ddd;
text-align: center;
background-color: #f3f3f3;
padding-top: 4px;
margin: 10px;
-moz-border-radius: 3px;
-khtml-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
}

.wp-caption img {
margin: 0;
padding: 0;
border: 0 none;
}

.wp-caption p.wp-caption-text {
font-size: 11px;
line-height: 17px;
padding: 0 4px 5px;
margin: 0;
}
/* End captions */

If you wish to know and understand more about alignement issue, please take into account to visit these two WordPress forum’s topics click here and here.

Edit: Here is another couple of ways to disable the caption features in WP:

1) Add this to your theme’s functions.php file:
function no_caption($deprecated, $attr, $content) { return $content; };
add_filter(’img_caption_shortcode’, ‘no_caption’, 10, 3);

2) Alternatively, add this to your theme’s functions.php file:
define(‘CAPTIONS_OFF’, true);

3) Add this to your theme’s functions.php file: add_filter(‘disable_captions’, create_function(‘$a’,'return true;’));



Tags: trick, update, Wordpress

WP Greet Box icon
Hello there! If you are new here, you might want to subscribe to the RSS feed for updates on this topic.

Related Articles Latest Articles

If you can not find what you are looking for, you might want to try Google Advanced Search and get thousands of results, specifically selected for you.

Google Advanced Search
.

6 Comments to “WordPress 2.6, its new caption feature and the text alignement issue”

  1. Download Free Software Says:

    I’ve been battling (and losing) the issue of how to disable those stupid captions for days. I guess I just haven’t been googling the right thing. Thank you.

    Now I can start using the ALT text on my images. They looked stupid with the captions below it.

    Just 1 question… Does it matter where I put the code for:
    function no_caption($deprecated, $attr, $content) { return $content; };
    add_filter(’img_caption_shortcode’, ‘no_caption’, 10, 3);

    Thanks!

    Tim

  2. Web Talk Says:

    Hello there,
    No it doesn’t matter where you put the piece of code inside the functions.php file. If you want you can add a brief comment right before it to know where it is located, or you can just add this code at the beginning of the file.

  3. Download Free Software Says:

    Thank you. I appreciate that. I’ll put it in right now.

    Oh, and I’ll give you a link from one of my other blogs. =)

    Tim

  4. Web Talk Says:

    Thanks mate and continue reading Web Talk! :)

  5. Another WordPress Post… | Biden PC's Quick Notes Says:

    [...] but the captions looked horrible and off-center. So I found a post by Francesco that tells how to Center WordPress Captions. It works and looks [...]

  6. seguinsound.com/blog » Wordpress 2.6 Caption Alignment Fix Says:

    [...] this!  There is some issues with the new “captions” feature for images.  I found a great fix here which I am simply reposting [...]

Leave a Comment

If you want to show an image next to your comments, get your gravatar now!

XHTML - You can use the following tags:  <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv Enabled


Incoming Search Terms for the Article:

wordpress center caption - wordpress caption code - wordpress centering captions - how to center captions in wordpress - editing caption size wordpress - wordpress caption function - wordpress enable caption in search - wordpress com center caption - wordpress how to display featured image description and caption - wordpress image caption padding - wordpress center text - wordpress photo not centered over caption - wordpress center a caption - wordpress caption without frame - wordpress caption featured -

All contents are licenced under a Creative Commons Licence.
Best screen resolution 1280x800 or higher.
Web Talk is best viewed in Firefox.