Skip to content

Instantly share code, notes, and snippets.

@jawngee
Created April 10, 2021 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jawngee/f01c74f781b4e8cd4a6d40983e626b99 to your computer and use it in GitHub Desktop.
Save jawngee/f01c74f781b4e8cd4a6d40983e626b99 to your computer and use it in GitHub Desktop.
Prefix filter for adding custom tokens
<?php
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