Skip to content

Instantly share code, notes, and snippets.

Created Apr 10, 2021
What would you like to do?
Prefix filter for adding custom tokens
add_filter('media-cloud/storage/prefix', function($prefix, $postId) {
// Adds a @{id} token that will be replaced with the attachment's ID, or 0 if
// the attachment doesn't exist yet.
$prefix = str_replace("@{id}", $postId ?? 0, $prefix);
return $prefix;
}, 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment