Преглед изворни кода

lodestar: Sync D134558: Handle the case where there is no featured image (PHP 8.1 Warning) (#7609)

Matthew Reishus пре 1 година
родитељ
комит
658e37f64e
1 измењених фајлова са 4 додато и 2 уклоњено
  1. 4 2
      lodestar/components/header/header-image.php

+ 4 - 2
lodestar/components/header/header-image.php

@@ -20,9 +20,11 @@
 		elseif (
 			( is_post_type_archive( 'jetpack-portfolio' ) || is_tax( 'jetpack-portfolio-type' ) || is_tax( 'jetpack-portfolio-tag') || 'jetpack-portfolio' === get_post_type() ) && isset( $jetpack_portfolio_featured_image ) && '' != $jetpack_portfolio_featured_image ) :
 
-			$featured_image_attributes = wp_get_attachment_image_src( $jetpack_portfolio_featured_image, 'lodestar-featured-image' ); ?>
+			$featured_image_attributes = wp_get_attachment_image_src( $jetpack_portfolio_featured_image, 'lodestar-featured-image' );
+			$ft_image_url = is_array( $featured_image_attributes ) ? $featured_image_attributes[0] : false;
+			?>
 
-			<div class="custom-header-image" style="background-image: url(<?php echo esc_url( $featured_image_attributes[0] ); ?>)">
+			<div class="custom-header-image" <?php if ( $ft_image_url ) echo 'style="background-image: url(' . esc_url( $ft_image_url ) . ')"'; ?>>
 				<?php get_template_part( 'components/header/site', 'branding' ); ?>
 			</div>