Created
May 14, 2013 23:31
-
-
Save cnocon/5580574 to your computer and use it in GitHub Desktop.
The caption code we use in our CSS. Authored by Erik Runyon.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(window).load(function() { | |
$('.image-right img,.image-left img,.image-default img').each(function(i,e){ | |
var $this = $(this), /*1*/ | |
$parent = $this.parent('p'); /*2*/ | |
if($parent.text().trim().length > 0) { /*3*/ | |
$parent.addClass('captioned').css({ width: $this.outerWidth() }); /*4*/ | |
} | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment