I noticed that this plugin seems to break the Twenty Twenty-Four theme when you try to display an overview of all the recent postings with featured images. Effectively it looks like there are always two links, one empty one and one with a featured image. The actual post then looks fine and the featured image opens in a lightbox.
I managed to fix it by slightly changing the code:
function cfi_clickable_featured_image($html, $post_id, $post_thumbnail_id) {
$image_data = wp_get_attachment_image_src($post_thumbnail_id, 'full');
// Check if $image_data is false, and if so, return the original $html.
if ($image_data === false) {
return $html;
}
$caption = get_the_title($post_thumbnail_id);
if (is_singular()) {
$html = '<a href="' . $image_data[0] . '" data-caption="' . esc_attr($caption) . '" class="wp-block-image">' . $html . '</a>';
} /* else {
$post_url = get_permalink($post_id);
$html = '<a href="' . $post_url . '">' . $html . '</a>';
} */
return $html;
}
However the else case was probably there for a reason, so I assume that this change will break something else. Could someone tell me what the else case was for, so that we can have a proper fix?
]]>