• I’m having a issue with the new image caption feature in WordPress 2.6. Apparently it is automatically adding 10px to the width of the caption div surrounding the image:

    <div class=”wp-caption alignright” style=”width: 347px”><img style=”width: 337px; height: 450px;”…

    Does anyone know why this is, and how I might fix it so that the width of the caption div is the same as the image?

Viewing 10 replies - 16 through 25 (of 25 total)
  • Freakin sweeeet! thanks.

    @revolutionfrance:

    Ah, damn… yeah on a client’s site on MediaTemple, I’m getting the same error…

    dreamhost is fine… :-/

    Ah found it.

    This plugin only works php 5. Works now. woo!

    And, commenting on this, if wp devels are going to fix this I would get rid of the hardcoded inline style too.

    @jpadie how do i install this plugin? i’m not familiar with installation from a text file. thanks.

    This hardcoded 10px padding is really annoying. WP devs, please remove these kinds of dabbling with the style.

    The plugin works great though, thanks jpadie.

    Great plugin! Those extra hard coded 10 pixels have been driving me bonkers!

    Oh, and reverb09, just save the text file as FixImageMargins.php and upload it to your plugins directory. Then you can activate it from your admin panel.

    @reverb09
    save the text to a new file in wp-content/plugins. does not matter what it’s called. as The Monkeyboy says.

    @revolutionfrance
    the code is OOP and so properly compatible only with php5. it’s easy enough to convert to php4 though. delete the word ‘public’ in the method declarations and change ‘public’ to ‘var’ in the property declaration

    @xamataca
    i agree- this is a rare example of very poor core coding.

    Another hour gone to WordPress issues! (not happy)

    I wanted to change this frame around the images, too. As an artist and cartoonist, would like to note that the caption below is a great addition, but the grey on top and sides is distracting, and too thick.

    Anyway, am not able to change to php4, jpadie.

    Here is what I did: it mentions public 3 times, so changed according to you and instructions I found online to:

    var $xs = 0; //change this to change the amount of extra spacing
    
          function  fixImageMargins(){ 
    
            add_filter('img_caption_shortcode', array(&$this, 'fixme'), 10, 3);
        }
           function fixme($x=null, $attr, $content){

    But am still getting error message in 2.7.1. I don’t understand php, am just copying.

    Anyone can help with this php coding to get it to work in php4?
    Thanks!

    Oops, just tried to change something else, too, so to help others, for php it should be:

    var $xs = 0; //change this to change the amount of extra spacing
    
          function  fixImageMargins(){ 
    
            add_filter('img_caption_shortcode', array(&$this, 'fixme'), 10, 3);
        }
           function fixImageMargins($x=null, $attr, $content){

    And it seems to work!

    The top of the frame is still a little thicker than I would like, but it’s great to have the side frames only one px borders.

Viewing 10 replies - 16 through 25 (of 25 total)
  • The topic ‘10px added to width in image captions?’ is closed to new replies.