WordPress.org

Ready to get started?Download WordPress

Forums

WP Fluid Images
Major Caption Bug (1 post)

  1. davidddn
    Member
    Posted 1 year ago #

    I found and fixed a major issue with captions.

    To reproduce, in the body of a post, have a small (250 pixel) image followed by a 500px image. Captions on both.

    The javascript will use the caption div width of the first smaller image for calculations on the second larger image, resulting in a shrunken image.

    Fix:

    Lines 31-37:

    var capw = jQuery('.wp-caption').width();
    // Remove the style attribute from .wp-caption
    jQuery('.wp-caption').removeAttr('style');
    // Calculate the width of .wp-caption as a percentage of the width of .hentry
    var caperc = ((capw / postw) * 100);
    // Write a style attribute with width as a percentage
    jQuery('.wp-caption').attr('style','width:' + caperc + '%;');

    to

    var capw = jQuery(this).parent('.wp-caption').width();
    // Remove the style attribute from .wp-caption
    jQuery('.wp-caption').removeAttr('style');
    // Calculate the width of .wp-caption as a percentage of the width of .hentry
    var caperc = ((capw / postw) * 100);
    // Write a style attribute with width as a percentage
    jQuery(this).parent('.wp-caption').attr('style','width:' + caperc + '%;');

    http://wordpress.org/extend/plugins/wp-fluid-images/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.