fix: fall back to placeholder art when a cover attachment is gone

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
chrnxandClaude Opus 5 committed 2026-08-15 15:34:37 -05:00
1 parent 77dc2ee33b
commit 6f418f1a51
9 files changed
+80 -23

No files matched your search

+9 -8
View File
@@ -10,12 +10,13 @@ if ( ! $chrnx_term instanceof WP_Term || 'chrnx_release' !== $chrnx_term->taxono
return;
}
$chrnx_heading = chrnx_get_heading_level( $attributes['headingLevel'] ?? 2, 2 );
$chrnx_status = (string) get_term_meta( $chrnx_term->term_id, 'chrnx_release_status', true );
$chrnx_cover = absint( get_term_meta( $chrnx_term->term_id, 'chrnx_release_cover', true ) );
$chrnx_links = chrnx_get_release_links( $chrnx_term->term_id );
$chrnx_tracks = chrnx_get_release_track_ids( $chrnx_term->slug );
$chrnx_track_h = min( 6, $chrnx_heading + 1 );
$chrnx_heading = chrnx_get_heading_level( $attributes['headingLevel'] ?? 2, 2 );
$chrnx_status = (string) get_term_meta( $chrnx_term->term_id, 'chrnx_release_status', true );
$chrnx_cover = absint( get_term_meta( $chrnx_term->term_id, 'chrnx_release_cover', true ) );
$chrnx_links = chrnx_get_release_links( $chrnx_term->term_id );
$chrnx_cover_markup = $chrnx_cover > 0 ? wp_get_attachment_image( $chrnx_cover, 'large', false, array( 'class' => 'chrnx-release-detail__cover' ) ) : '';
$chrnx_tracks = chrnx_get_release_track_ids( $chrnx_term->slug );
$chrnx_track_h = min( 6, $chrnx_heading + 1 );
// Without status, description or links there is no second column to fill.
$chrnx_has_intro = '' !== $chrnx_status || '' !== $chrnx_term->description || ! empty( $chrnx_links );
$chrnx_head_class = 'chrnx-release-detail__head' . ( $chrnx_has_intro ? '' : ' is-bare' );
@@ -23,8 +24,8 @@ $chrnx_head_class = 'chrnx-release-detail__head' . ( $chrnx_has_intro ? '' : ' i
<section <?php echo get_block_wrapper_attributes( array( 'class' => 'chrnx-release-detail' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
<div class="<?php echo esc_attr( $chrnx_head_class ); ?>">
<div class="chrnx-release-detail__art">
<?php if ( $chrnx_cover > 0 ) : ?>
<?php echo wp_get_attachment_image( $chrnx_cover, 'large', false, array( 'class' => 'chrnx-release-detail__cover' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php if ( '' !== $chrnx_cover_markup ) : ?>
<?php echo $chrnx_cover_markup; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php else : ?>
<?php echo chrnx_get_topic_portrait_markup( 'placeholder-release', '', 'chrnx-release-detail__fallback' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Helper returns escaped, allowlisted markup. ?>
<?php endif; ?>