Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MichaelVanDenBerg/704d3aa916643462646eaecbf0bcbe50 to your computer and use it in GitHub Desktop.
Save MichaelVanDenBerg/704d3aa916643462646eaecbf0bcbe50 to your computer and use it in GitHub Desktop.
Add .large class to the <p> parent of images wider than 680px. This used to break out large images in posts and pages in the Alpha Centauri WordPress theme.
// Add .large class to the <p> parent of images wider than 680px.
$( '.entry-content img' ).each( function() {
var $this = $( this );
if ( ( $this.attr( 'width' ) > 680 ) && ( $this.parent().is( 'p' ) ) ) {
$this.parent().addClass( 'large' );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment