CCK 6.x-2.3
ImageField 6.x-3.0
Public download method
I'd like to replace the label and description for both the 'title' and 'alt' fields on the node edit page, since I'm hijacking those for a caption and photo credit. I looked at the $form array for awhile, and tried editing $form['0']['data']['alt']['#title'], etc., but this only had an impact on the fields in question when I went to edit an existing node. (Presumably because that value only refers to the 0th instance of the imagefield.)
I notice that imagefield_widget.inc seems to set alt_settings and title_settings, and that sounds more promising, but I'm unclear how to override those values.
Thank you.
Comments
Comment #1
quicksketchYou can override these element labels in a couple of different ways. The most common approach would be to theme the fields. Take the "theme_filefield_widget_item" function in the filefield_widget.inc file, copy it into template.php, rename it to nameofyourtheme_filefield_widget_item, then modify the labels that way. I think they're in $element['data']['title'] and $element['data']['alt'].
Comment #2
quicksketchClosing after lack of response.
Comment #3
lrickard commentedThis worked great! I apologize for for not responding, and I'm posting back to help anyone who finds this later on.
I followed quicksketch's solution, and overrode the theme_filefield_widget_item() function:
function mythemename_filefield_widget_item($element) {
--snip--
$element['data']['alt']['#title'] = "Caption";
$element['data']['alt']['#description'] = "Whatever description you want users to see";
$element['data']['title']['#title'] = "Credit";
$element['data']['title']['#description'] = "Whatever description you want users to see";
--snip--
}
So, note to others. The $form element doesn't hold this information - it's kept in the filefield module and can be overridden.
Comment #4
jasonawantHi,
I tried the above solution, but it didn't seem to work for me. I think I'm missing something, particularly the parts that lrickard noted as '--snip--'. After a few attempts, some success with the following. Note, I only wanted to change the Title label and description.
Comment #5
gngn commentedYou just need to overwrite theme_imagefield_widget_item() - which just calls theme_filefield_widget_item().
This way you're changes will affect only imagefields (instead of all filefields).