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
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
divin 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.
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.
- The topic ‘Attached Image Captions adding 10px’ is closed to new replies.