• Hi all,
    When I add captions to images, code is inserted that creates a div with width 1000 at the element level. Here’s an example:
    Sample blog post

    You can see that the images without captions are formatted correctly. When I look at the html from inside the editor, I see:
    [caption id="attachment_638" align="aligncenter" width="1000" caption="Banana bread and chips were vital to the DAC processing"]<a href="https://blog.wingedvictorydesign.com/wp-content/uploads/2009/05/whiteboard-concept-1.jpg"><img class="size-full wp-image-638" title="concept" src="https://blog.wingedvictorydesign.com/wp-content/uploads/2009/05/whiteboard-concept-1.jpg" alt="Banana bread and chips were vital to the DAC processing" width="1000" height="750" /></a>[/caption]

    So it seems that the caption shortcode is adding a width of 1000, rather than the maximum image width specified for the blog.

    How do I fix this? Is it a theme problem (I’m using Elegant Grunge), or a core wordpress code problem, or what?

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The caption div is 1000px wide because your image is 1000px wide.

    <img class="size-full wp-image-638" title="concept" src="https://blog.wingedvictorydesign.com/wp-content/uploads/2009/05/whiteboard-concept-1.jpg" alt="Banana bread and chips were vital to the DAC processing" width="1000" height="750" />

    Try using the medium or thumbnail image option.

    Thread Starter ohnoesitasploded

    (@ohnoesitasploded)

    But photos without captions are sized correctly, even though they’re uploaded at the same size.

    One of the features I really like about WordPress is that it will resize your large photos for you so that you don’t have to screw around with formatting all the time. Seems like the caption code should also respect the maximum image size.

    Anyway, even if I wanted to format the pictures as “large” size, the option is grayed out in the image manager. And I’m using medium and thumbnail sizes elsewhere, I can’t change them.

    Any help appreciated.

    Thread Starter ohnoesitasploded

    (@ohnoesitasploded)

    Okay, the “large” photo size is not grayed out in Google Chrome, so I can use that to format the pictures correctly (I was using Firefox).

    But, the caption code should handle images identically to the rest of WordPress, so I’m calling that a bug.

    Thread Starter ohnoesitasploded

    (@ohnoesitasploded)

    Also, the “use google chrome” workaround doesn’t fix the existing posts…

    Where is the caption shortcode processed? For the life of me I can’t find it…

    Thread Starter ohnoesitasploded

    (@ohnoesitasploded)

    Any help on this would be appreciated… My existing posts are all screwed up…

    Proper sizing of your images is a straight forward simple fix. It is also good etiquette, as it saves bandwidth… Not only your bandwidth, but possibly the bandwidth of someone on a “limited bandwidth” wireless connection.

    Thread Starter ohnoesitasploded

    (@ohnoesitasploded)

    Hmmmm… I disagree. Re-formatting and re-uploading all of the images in my existing posts is neither simple nor straightforward.

    Also, I write mostly technical how-to posts, and many of my images have small details for which it is helpful to be able to click on the image to enlarge it.

    Also, in the Future when we are using higher resolution monitors when we’re not gadding about on rocket packs, I want to be able to adjust my site layout by changing around some CSS, rather than rebuilding the entire site.

    “Solution: Don’t Do That” posts are rarely helpful.

    I figured out a dumb hack/workaround:
    In Media.php, line 580, change the line:
    return '<div ' . $id . 'class="wp-caption ' . $align . '" style="width: ' . (10 + (int) $width) . 'px">'
    to:
    return '<div ' . $id . 'class="wp-caption ' . $align . '" style="width: XXXpx">'
    Where XXX is your desired width for the containing div in pixels.

    But, this function should really just return the maximum width that you set for images in the WP options, like images without captions.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Image width wider than blog when using captions’ is closed to new replies.