themes-wordpress/canard/js/featured-content.js
2018-02-27 14:18:25 +11:00

22 lines
623 B
JavaScript

( function( $ ) {
$( window ).load( function() {
/* Use Featured Image as a Background Image */
var featuredContent = $( '#featured-content' );
if ( ! featuredContent.length ) {
return;
}
featuredContent.find( 'article' ).each( function() {
if ( ! $( this ).hasClass( 'background-done' ) && $( this ).hasClass( 'has-post-thumbnail' ) ) {
var entryImage = $( this ).find( '.post-thumbnail' ),
thumbnail = $( this ).find( 'img' );
entryImage.css( 'background-image', 'url(' + thumbnail.attr( 'src' ) + ')' );
$( this ).addClass( 'background-done' );
}
} );
} );
} )( jQuery );