WordPress.org

Ready to get started?Download WordPress

Forums

WP adding style with extra 10px.. Where? (5 posts)

  1. cesbloggan
    Member
    Posted 3 years ago #

    Hi,
    I am tweaking TwentyTen and stumbled on a problem..
    It seems that when inserting left-aligned pictures in pages WP adds: style="width: 650px" to the image which means an extra 10 px to the image's actual width. It doesn't show in html-mode either as it does if you add margin in the advanced preferences for the image.
    Since it gets created directly in the page I can't take it away in the style-sheet. It doesn't make a change either to use negative margins in the style-sheet.

    The result creates a 10px space to the left of the picture.

    Where is it initiated? Any WP-guru out there to help?

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    afaik, this happens only for images with captions;

    http://www.transformationpowertools.com/wordpress/adjust-caption-frame-width

    can you post a link to your site to illustrate the problem?

  3. cesbloggan
    Member
    Posted 3 years ago #

    Thanks!
    I read the post and copied the code into functions.php and it works like a charm!
    Of course it was an image with a caption but I want to have the possibility of using captions and not having to add extra code to format regular text like a caption.
    :-)

  4. ryanve
    Member
    Posted 3 years ago #

    The extra 10px can also be removed using jQuery. The code below sets the .wp-caption container width to match the width of the image inside it:

    jQuery().ready(function() {
    	var width = jQuery(".wp-caption img").width();
    	jQuery(".wp-caption").width(width);
    	});

    See this thread.

  5. ryanve
    Member
    Posted 3 years ago #

    Actually this version is more solid:

    jQuery().ready(function( jQuery ) {
        jQuery(".wp-caption").width(function() {
            return jQuery('img', this).width();
        });
    });

    See this thread.

Topic Closed

This topic has been closed to new replies.

About this Topic