function file_token_info

Same name in other branches
  1. 9 core/modules/file/file.module \file_token_info()
  2. 8.9.x core/modules/file/file.module \file_token_info()
  3. 11.x core/modules/file/file.module \file_token_info()

Implements hook_token_info().

File

core/modules/file/file.module, line 853

Code

function file_token_info() {
    $types['file'] = [
        'name' => t("Files"),
        'description' => t("Tokens related to uploaded files."),
        'needs-data' => 'file',
    ];
    // File related tokens.
    $file['fid'] = [
        'name' => t("File ID"),
        'description' => t("The unique ID of the uploaded file."),
    ];
    $file['name'] = [
        'name' => t("File name"),
        'description' => t("The name of the file on disk."),
    ];
    $file['path'] = [
        'name' => t("Path"),
        'description' => t("The location of the file relative to Drupal root."),
    ];
    $file['mime'] = [
        'name' => t("MIME type"),
        'description' => t("The MIME type of the file."),
    ];
    $file['size'] = [
        'name' => t("File size"),
        'description' => t("The size of the file."),
    ];
    $file['url'] = [
        'name' => t("URL"),
        'description' => t("The web-accessible URL for the file."),
    ];
    $file['created'] = [
        'name' => t("Created"),
        'description' => t("The date the file created."),
        'type' => 'date',
    ];
    $file['changed'] = [
        'name' => t("Changed"),
        'description' => t("The date the file was most recently changed."),
        'type' => 'date',
    ];
    $file['owner'] = [
        'name' => t("Owner"),
        'description' => t("The user who originally uploaded the file."),
        'type' => 'user',
    ];
    return [
        'types' => $types,
        'tokens' => [
            'file' => $file,
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.