This repository has been archived by the owner on May 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed post image appearance for posts without a featured image.
- Loading branch information
Showing
1 changed file
with
28 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,37 @@ | ||
<?php | ||
$post_format = get_post_format() ?: 'standard'; | ||
$image_icon = '<div class="media-wrapper--icon flex items-center justify-center">' . | ||
\Garrick\get_svg( [ 'icon' => 'format-' . $post_format, 'class' => 'icon--md color-inherit' ] ) . | ||
'</div>'; | ||
|
||
$image_label = ''; | ||
$days = get_theme_mod( 'archive_new_days_count', false ); | ||
if ( $days > 0 && ( time() - ( 86400 * $days ) ) < get_the_date( 'U' ) ) : | ||
$image_label = '<div class="media-wrapper--label">' . __( 'New', 'garrick' ) . '</div>'; | ||
endif; | ||
|
||
if ( has_post_thumbnail() && '' != get_the_post_thumbnail_url() ) : | ||
$image_icon = '<div class="media-wrapper--icon flex items-center justify-center">' . | ||
\Garrick\get_svg( [ 'icon' => 'format-' . $post_format, 'class' => 'icon--md color-inherit' ] ) . | ||
'</div>'; | ||
$image_label = ''; | ||
|
||
if ( $days > 0 && ( time() - ( 86400 * $days ) ) < get_the_date( 'U' ) ) : | ||
$image_label = '<div class="media-wrapper--label">' . __( 'New', 'garrick' ) . '</div>'; | ||
endif; | ||
|
||
Hybrid\Carbon\Image::display( 'featured', [ | ||
'size' => 'full', | ||
'class' => 'entry__image radius-md', | ||
'before' => '<figure class="margin-y-sm color-contrast-low media-wrapper media-wrapper--4:3 bg-contrast-lower radius-md position-relative">' . $image_icon . $image_label, | ||
'after' => '</figure>', | ||
'link' => true, | ||
'link_class' => 'entry__featured-image__link', | ||
] ); | ||
else : | ||
?> | ||
<?php if ( has_post_thumbnail() && '' != get_the_post_thumbnail_url() ) : ?> | ||
<?php Hybrid\Carbon\Image::display( 'featured', [ | ||
'size' => 'full', | ||
'class' => 'entry__image radius-md', | ||
'before' => '<figure class="margin-y-sm color-contrast-low media-wrapper media-wrapper--4:3 bg-contrast-lower radius-md position-relative">' . $image_icon . $image_label, | ||
'after' => '</figure>', | ||
'link' => true, | ||
'link_class' => 'entry__featured-image__link', | ||
] ) ?> | ||
<?php else : ?> | ||
<a href="<?php echo esc_url( get_permalink() ) ?>" class="entry__featured-image__link color-contrast-low" aria-hidden="true"> | ||
<div class="margin-y-sm color-contrast-low media-wrapper media-wrapper--4:3 bg-contrast-lower radius-md position-relative"> | ||
<?php echo $image_label ?> | ||
<?php echo $image_icon ?> | ||
<?php if ( $days > 0 && ( time() - ( 86400 * $days ) ) < get_the_date( 'U' ) ) : ?> | ||
<div class="media-wrapper--label"> | ||
<?php echo esc_html( 'New', 'garrick' ) ?> | ||
</div> | ||
<?php endif ?> | ||
<div class="media-wrapper--icon flex items-center justify-center"> | ||
<?php echo \Garrick\get_svg( [ 'icon' => 'format-' . $post_format, 'class' => 'icon--md color-inherit' ] ) ?> | ||
</div> | ||
</div> | ||
</a> | ||
<?php endif; ?> |