I am hoping to get the field name inside hook_preprocess_file_link()
.
I only want to alter the link of the file for certain field names.
hook_preprocess_field()
would probably work, but I would prefer to use hook_preprocess_file_link()
.
Is it possible to get the field name in this hook?
mymodule.module
function mymodule_preprocess_file_link(&$variables, $fieldName) {
// This returns "file_link" instead of the field name like "field_myfilefield".
kpr($fieldName);
}
function mymodule_preprocess_field(&$variables) {
if (isset($variables['field_name'])) {
$fieldName = $variables['field_name'];
}
mymodule_preprocess_file_link($variables, $fieldName);
}