diff --git a/token.test b/token.test index 9988256..94e3cd9 100644 --- a/token.test +++ b/token.test @@ -1039,6 +1039,7 @@ class TokenFileTestCase extends TokenTestHelper { $tokens = array( 'basename' => 'test.png', + 'filename' => 'test', 'extension' => 'png', 'size-raw' => 100, ); @@ -1050,6 +1051,7 @@ class TokenFileTestCase extends TokenTestHelper { $tokens = array( 'basename' => 'test', + 'filename' => 'test', 'extension' => '', 'size-raw' => 100, ); diff --git a/token.tokens.inc b/token.tokens.inc index f584bda..a2ec147 100644 --- a/token.tokens.inc +++ b/token.tokens.inc @@ -170,6 +170,10 @@ function token_token_info() { 'name' => t('Base name'), 'description' => t('The base name of the file.'), ); + $info['tokens']['file']['filename'] = array( + 'name' => t('Filename'), + 'description' => t('The name of the file without the extension.'), + ); $info['tokens']['file']['extension'] = array( 'name' => t('Extension'), 'description' => t('The extension of the file.'), @@ -543,6 +547,10 @@ function token_tokens($type, $tokens, array $data = array(), array $options = ar $basename = pathinfo($file->uri, PATHINFO_BASENAME); $replacements[$original] = $sanitize ? check_plain($basename) : $basename; break; + case 'filename': + $filename = pathinfo($file->uri, PATHINFO_FILENAME); + $replacements[$original] = $sanitize ? check_plain($filename) : $filename; + break; case 'extension': $extension = pathinfo($file->uri, PATHINFO_EXTENSION); $replacements[$original] = $sanitize ? check_plain($extension) : $extension;