Infinite Uploads provides a developer hook that allows plugins and themes to exclude specific local paths from being offloaded to the Infinite Uploads cloud. This is especially useful when third-party plugins store backups, temporary assets, or processing files that should remain on the server.
The example below demonstrates how ShortPixel integrates with Infinite Uploads to ensure its backup directory is never synced to cloud storage.
Overview
The infinite_uploads_sync_exclusions filter makes it possible to append custom directory rules that prevent certain files or folders within wp-content/uploads/ from being offloaded.
Infinite Uploads always processes local media through its internal sync routines. Using this filter gives developers control over which paths should be skipped during the offload process.
Usage Example
Here is a full example of how to use the filter to exclude the ShortPixel backup directory:
add_filter( 'infinite_uploads_sync_exclusions', 'compatibility_exclusions' );
function compatibility_exclusions( $exclusions ) {
// Add the ShortPixel backups folder to the exclusion list
$exclusions[] = 'wp-content/uploads/ShortpixelBackups/';
return $exclusions;
}
This ensures that the following path will always remain local:
wp-content/uploads/folder/
Infinite Uploads merges your exclusions with its own internal defaults during sync operations.
Parameters
$exclusions
(array)
A list of directory paths (relative to the WordPress root) that Infinite Uploads will skip when performing sync/offload operations.
Each value should be:
- a string,
- representing a relative path,
- ending with a trailing slash.
Example:
$exclusions[] = 'wp-content/uploads/custom-folder/';
When to Use This Filter
Use infinite_uploads_sync_exclusions when you need to ensure:
- Backup folders are never offloaded
- Plugins generate temporary processing files
- Generated assets should remain local
- Uploads created by automation tasks shouldn’t be stored in the cloud
- Sensitive files require local-only storage
Best Practices
- Always include the full relative path starting after the WordPress installation root.
- Always end paths with a trailing slash.
- Keep exclusions narrow—excluding entire upload years or months may affect normal media behavior.
- Avoid excluding folders that hold standard WordPress media items.
Additional Developer Resources
If you are also integrating deeper Infinite Uploads functionality, here are related APIs available (shown in your integration notes for convenience):
Check if a File Is Offloaded
infinite_uploads_check_offloaded( $url );
Offload or Download a File Programmatically
$admin = new Infinite_Uploads_Admin();
$admin->offload_image( '/2025/05/example.png' );
$admin->download_image( '/2025/05/example.png' );
Delete File From Cloud Storage
$iu = new Infinite_Uploads();
$iu->infinite_uploads_delete_files_from_cloud( $attachment_id );
Retrieve the Site CDN URL
$api = Infinite_Uploads_Api_Handler::get_instance();
$data = $api->get_site_data();
$cdn = $data->site->cdn_url;