Forums

Image captions don't work with dimension (5 posts)

  1. yameng
    Member
    Posted 1 year ago #

    The theme doesnt seem to let image caption resize with the image size. The inserted image either sticks out of the caption or the caption doesn't fit and is too wide for it...
    I also noticed that I cannot resize the image sizes somehow...? they stay at that restricted format...

  2. alchymyth
    The Sweeper
    Posted 1 year ago #

    edit style.css of TwentyTen, find:

    #content img {
    margin: 0;
    height: auto;
    max-width: 640px;
    width: auto;}

    remove width: auto; ...

  3. danielPh
    Member
    Posted 1 year ago #

    I am also not being able to resize images from within the html image tag.
    The above solution does not seem to help.

  4. Marlimant
    Member
    Posted 10 months ago #

    Put the code of this page in your functions.php http://www.transformationpowertools.com/wordpress/adjust-caption-frame-width here is the explanation and the solution of your problem.

  5. Marlimant
    Member
    Posted 10 months ago #

    The code:

    add_shortcode('wp_caption', 'slim_img_caption_shortcode');
    add_shortcode('caption', 'slim_img_caption_shortcode');
    function slim_img_caption_shortcode($attr, $content = null) {
     // Allow plugins/themes to override the default caption template.
     $output = apply_filters('img_caption_shortcode', '', $attr, $content);
     if ( $output != '' )
     return $output;
    
     extract(shortcode_atts(array(
     'id'    => '',
     'align'    => 'alignnone',
     'width'    => '',
     'caption' => ''
     ), $attr));
    
     if ( 1 > (int) $width || empty($caption) )
     return $content;
    
     if ( $id ) $id = 'id="' . esc_attr($id) . '" ';
    
     $frame_width = 0; // frame width in pixels per side //
    
     return '<div ' . $id . 'class="wp-caption ' . esc_attr($align) . '" style="width: ' . ( 2 * $frame_width + (int) $width) . 'px">'
     . do_shortcode( $content ) . '<p class="wp-caption-text">' . $caption . '</p></div>';
    }

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags