• Dear WordPress staff,

    I really like WordPress 2.6’s image caption feature, but it doesn’t respect my maximum width for images, which is set to 530 pixels in my functions.php file. Whenever I upload an image, if I use the medium size it’s just fine, 530px max. However, if I ask it add a caption below, it adds 10 pixels more, going to 540 pixels. I don’t want that.

    Can you fix it, please?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Ditto.

    If you don’t mind poking around in the php, you can change this width- I had the same problem and found the culprit at line 375 of media.php:

    return '<div ' . $id . 'class="wp-caption ' . $align . '" style="width: ' . (10 + (int) $width) . 'px">'

    Just change ’10’ to whatever pixel width addition you require. None, in my case.

    This should really be configurable in the editor, though, I agree.

    Ciao!

    I totaly agree that the addition of this style-rule is agaist all good practices of seperating form and content.

    Let’s hope its a bug that will be removed from media.php soon.

    For now, I deleted the entire style-rule from the php-code. Now I hope I’ll remember to check on media.php everytime I upgrade WP.

    midstatelitho

    (@midstatelitho)

    I’m not seeing the entry in media.php that adds the 10px. Perhaps I’m missing something. I’m using wordpress 2.6.3

    joelhardi

    (@joelhardi)

    I just found this and am also annoyed. The thing I’d point out is that, for floated elements, it’s a requirement of the CSS2 spec that an explicit width be specified, so WordPress is doing the right thing by specifying a width. However, hardcoding the extra 10px being added on deep in the application is totally braindead!

    I would definitely mark this as a bug until it’s removed. Here’s a patch to fix it:

    --- media-old.php       2008-11-21 18:01:11.000000000 -0800
    +++ media.php   2008-11-21 18:01:38.000000000 -0800
    @@ -372,7 +372,7 @@
    
            if ( $id ) $id = 'id="' . $id . '" ';
    
    -       return '<div ' . $id . 'class="wp-caption ' . $align . '" style="width: ' . (10 + (int) $width) . 'px">'
    +       return '<div ' . $id . 'class="wp-caption ' . $align . '" style="width: ' . (int) $width . 'px">'
            . $content . '<p class="wp-caption-text">' . $caption . '</p></div>';
     }

    I wrote a little bit more about the CSS requirement on this bug report:

    https://www.ads-software.com/support/topic/189254

    and here’s a plugin that will do this without a core hack.
    https://www.ads-software.com/support/topic/189254?replies=13#post-925819

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Control of image caption width’ is closed to new replies.