浏览代码

Updated JS to changed the featured image height

The code looks at the size of the header and compares it to the default ( Window.width * 1.33 ), and sets the image to the larger of the two. Fixes #284
Chris Runnells 6 年之前
父节点
当前提交
c1b186c860
共有 1 个文件被更改,包括 18 次插入4 次删除
  1. 18 4
      radcliffe-2/assets/js/radcliffe-2.js

+ 18 - 4
radcliffe-2/assets/js/radcliffe-2.js

@@ -21,10 +21,26 @@
 	function fullScreenImages() {
 		var $entryBackground = $( '.entry-thumbnail' ),
 			$heroArea        = $( '.hero-area' ),
-			$windowWidth     = $window.width();
+			$windowWidth     = $window.width(),
+			$height			 = Math.round( $windowWidth / 1.33 );
 
 		if ( $entryBackground ) {
-			$entryBackground.height( Math.round( $windowWidth / 1.33 ) + 'px' );
+			// if we're on a blog/archive page, there may be more than one
+			if ( $entryBackground.length > 1 ){
+				$entryBackground.each( function() {
+					// reset the height
+					$this_height = $height;
+					// find the .entry-header height
+					$entryHeader = $( this ).siblings( '.entry-header' );
+					if ( $height < $entryHeader.outerHeight() ) {
+						// pick the taller of the two
+						$this_height = $entryHeader.outerHeight();
+					}
+					$( this ).height( $this_height + 'px' );
+				} );
+			} else {
+				$entryBackground.height( Math.round( $windowWidth / 1.33 ) + 'px' );
+			}
 		}
 
 		if ( $heroArea && $windowWidth > '768' ) { // Set a fixed height for larger screens
@@ -33,8 +49,6 @@
 		else if ( $heroArea ) { // Set a min-height for smaller screens
 			$heroArea.css( { 'min-height' : Math.round( $windowWidth / 1.33 ) + 'px', 'height' : 'auto' } );
 		}
-
-		$entryBackground.height( Math.round( $windowWidth / 1.33 ) + 'px' );
 	}
 
 	// Add SVG image zoom icon