WordPress.org

Support

Support » Themes and Templates » [Resolved] Attached Image Captions adding 10px

[Resolved] Attached Image Captions adding 10px

Viewing 5 replies - 1 through 5 (of 5 total)
  • line 375 in wp-includes/media.php

    change 10 to 0

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

    I would unmark this as “resolved” if I were you … to me this “feature” is a bug. This kind of thing shouldn’t be hardcoded deep in a core WP library. It should either be removed entirely (which I would prefer) or be configurable via the Settings (there are already places under the Miscellaneous panel where image thumbnail sizes are set) or as a PHP constant or global you can define in your theme.

    I don’t get why they did this. It’s so easy to just do

    .wp-caption {
    padding: 0 5px 0 5px;
    }

    or whatever to achieve the same visual effect.

    This is annoying in my case because I don’t want this extra gap around my images. The CSS2 spec says you have to define a width for any floated element (the div in this case) so I appreciate what WP is trying to do, I just wish it wouldn’t add the 10px!

    i posted a plugin solution in this thread.
    http://wordpress.org/support/topic/189254?replies=13#post-925819

    the code actually adds a hardcoded element style width of 10px + the image width to the html:

    style="width: ' . (10 + (int) $width) . 'px"

    so then in your html you have:

    <div style="width: 810px">...</div>

    For every single captioned picture in your site. Which just seems like bad code to me. Stuff like this is what CSS was invented for.

    I took out that whole part, rather than just the 10px padding, and my stuff still looks fine in IE, FF, and Chrome.

    I dont like that +10px thing neither, can someone tell me why they added it, and why they keep it?

    Is like a workaround to something..?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] Attached Image Captions adding 10px’ is closed to new replies.