featured-content.js 623 B

12345678910111213141516171819202122
  1. ( function( $ ) {
  2. $( window ).load( function() {
  3. /* Use Featured Image as a Background Image */
  4. var featuredContent = $( '#featured-content' );
  5. if ( ! featuredContent.length ) {
  6. return;
  7. }
  8. featuredContent.find( 'article' ).each( function() {
  9. if ( ! $( this ).hasClass( 'background-done' ) && $( this ).hasClass( 'has-post-thumbnail' ) ) {
  10. var entryImage = $( this ).find( '.post-thumbnail' ),
  11. thumbnail = $( this ).find( 'img' );
  12. entryImage.css( 'background-image', 'url(' + thumbnail.attr( 'src' ) + ')' );
  13. $( this ).addClass( 'background-done' );
  14. }
  15. } );
  16. } );
  17. } )( jQuery );