Description
Filter whether the file of an attachment exists. Video Hub uses it to find featured images whose file is missing from the server — in the Thumbnails tool, the Featured image option of the Update videos tool and the Import thumbnails action. Plugins that keep media files on other servers (offloaded media, CDNs) can report their files as existing, so the thumbnails aren’t imported again. Available since Video Hub 2.3.3.
Parameters
- $exists
- (bool)(required) Whether the file exists on the server.
- $attachment_id
- (int)(required) Attachment ID.
- $file
- (string|bool)(required) Path to the file; false when the attachment has no file.
Examples
Treat attachments offloaded to a cloud storage as existing.
add_filter( 'cbc_attachment_file_exists', function( $exists, $attachment_id, $file ) {
if ( ! $exists && get_post_meta( $attachment_id, 'my_offload_url', true ) ) {
return true;
}
return $exists;
}, 10, 3 );