function runImageCover($id)
{
$attachments = get_posts([
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
'posts_per_page' => -1,
]);
foreach ($attachments as $attachment) {
$file = get_post_meta(
$attachment->ID,
'_wp_attached_file',
true
);
$basename = preg_replace(
'/-\d+x\d+$/',
'',
pathinfo($file, PATHINFO_FILENAME)
);
if ($basename === $id) {
return wp_get_original_image_url($attachment->ID);
}
}
return false;
}