/**
* Blog index featured images — fallback when core/post-featured-image renders empty in Query loops.
*/
/**
* Whether the current request is a blog listing surface.
*
* @return bool
*/
function rf_is_blog_listing_view() {
if (is_home() || is_archive() || is_search()) {
return true;
}
$posts_page = (int) get_option('page_for_posts');
if ($posts_page && is_page($posts_page)) {
return true;
}
return false;
}
/**
* Resolve post ID for a block inside a Query loop.
*
* @param WP_Block $block_instance
* @return int
*/
function rf_blog_loop_post_id($block_instance) {
if (is_object($block_instance) && !empty($block_instance->context['postId'])) {
return (int) $block_instance->context['postId'];
}
return (int) get_the_ID();
}
/**
* Build linked featured image markup for a post card.
*
* @param int $post_id
* @param bool $is_link
* @return string
*/
function rf_blog_featured_image_markup($post_id, $is_link = true) {
if (!$post_id || !has_post_thumbnail($post_id)) {
return '';
}
$image = get_the_post_thumbnail(
$post_id,
'large',
array(
'class' => 'attachment-post-thumbnail size-large wp-post-image',
'loading' => 'lazy',
'decoding' => 'async',
)
);
if ($image === '') {
return '';
}
$inner = $image;
if ($is_link) {
$inner = sprintf(
'%s',
esc_url(get_permalink($post_id)),
$image
);
}
return sprintf(
'%s',
$inner
);
}
/**
* @param string $block_content
* @param array $block
* @param WP_Block $block_instance
* @return string
*/
function rf_render_blog_featured_image($block_content, $block, $block_instance) {
if (!rf_is_blog_listing_view()) {
return $block_content;
}
if ($block_content !== '' && str_contains($block_content, '
]*class="[^"]*rf-blog-card[^"]*"[^>]*>)/',
'$1' . $markup,
$block_content,
1
);
return is_string($updated) && $updated !== '' ? $updated : $block_content;
}
add_filter('render_block_core/post-featured-image', 'rf_render_blog_featured_image', 10, 3);
add_filter('render_block_core/group', 'rf_render_blog_card_group', 10, 3);
Repair Factory - Trusted experts for Mac, PC, iPhone and Android
Repair Factory - Trusted experts for Mac, PC, iPhone and Android
Skip to content
The Repair Factory
Expert Fixes
Screens, batteries, and trusted device repair in Nelson, BC.
Start here
Most visits begin with a cracked screen or a tired battery. Pick your fix and we will take it from there.
Screen Replacement
Cracked iPhone, iPad, or Android glass? We replace screens quickly with quality parts and a clear price before we start.
Battery Replacement
Dying mid-day? Book a battery replacement for your laptop or phone and get back to a full charge.
More ways we help
Mac and PC specialists for repairs beyond the quick fixes.
Device Repair
iPhone, iPad, Android, Mac, and PC — dedicated technicians for the brands you actually use.
Virus & Malware Removal
Full system health checks, cleanups, and practical steps so the problem stays gone.
Data Recovery
Lost documents or a failing drive? We recover what we can and help you back up what matters.