{"id":3522144,"date":"2013-03-03T03:01:07","date_gmt":"2013-03-03T03:01:07","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/major-caption-bug\/"},"modified":"2016-08-20T22:24:40","modified_gmt":"2016-08-20T22:24:40","slug":"major-caption-bug","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/major-caption-bug\/","title":{"rendered":"Major Caption Bug"},"content":{"rendered":"<p>I found and fixed a major issue with captions.<\/p>\n<p>To reproduce, in the body of a post, have a small (250 pixel) image followed by a 500px image. Captions on both.<\/p>\n<p>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.<\/p>\n<p>Fix:<\/p>\n<p>Lines 31-37:<\/p>\n<p>\t\t\tvar capw = jQuery(&#8216;.wp-caption&#8217;).width();<br \/>\n\t\t\t\/\/ Remove the style attribute from .wp-caption<br \/>\n\t\t\tjQuery(&#8216;.wp-caption&#8217;).removeAttr(&#8216;style&#8217;);<br \/>\n\t\t\t\/\/ Calculate the width of .wp-caption as a percentage of the width of .hentry<br \/>\n\t\t\tvar caperc = ((capw \/ postw) * 100);<br \/>\n\t\t\t\/\/ Write a style attribute with width as a percentage<br \/>\n\t\t\tjQuery(&#8216;.wp-caption&#8217;).attr(&#8216;style&#8217;,&#8217;width:&#8217; + caperc + &#8216;%;&#8217;);<\/p>\n<p>to<\/p>\n<p>\t\t        var capw = jQuery(this).parent(&#8216;.wp-caption&#8217;).width();<br \/>\n                        \/\/ Remove the style attribute from .wp-caption<br \/>\n                        jQuery(&#8216;.wp-caption&#8217;).removeAttr(&#8216;style&#8217;);<br \/>\n                        \/\/ Calculate the width of .wp-caption as a percentage of the width of .hentry<br \/>\n                        var caperc = ((capw \/ postw) * 100);<br \/>\n                        \/\/ Write a style attribute with width as a percentage<br \/>\n                        jQuery(this).parent(&#8216;.wp-caption&#8217;).attr(&#8216;style&#8217;,&#8217;width:&#8217; + caperc + &#8216;%;&#8217;);<\/p>\n<p>https:\/\/wordpress.org\/extend\/plugins\/wp-fluid-images\/<\/p>\n","protected":false},"template":"","class_list":["post-3522144","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/3522144","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/3522144\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=3522144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}