Closed (fixed)
Project:
ImageField
Version:
5.x-2.1
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
25 Dec 2008 at 07:42 UTC
Updated:
24 Mar 2009 at 22:46 UTC
Hiho
I'm trying to edit the title and alt values of $file before it's passed to the content.module to be inserted into the DB.
So I implemented the hook module_invoke_all('imagefield_file', 'save', $file) like this:
function mymodule_imagefield_file($op, &$file) {
switch ($op) {
case 'save':
$file['alt'] = 'test 123';
$file['title'] = 'test 123';
break;
}
}
Any idea why this isn't changing the alt and title of the image to 'test 123'?
If I hack it directly into imagefield_file_insert() in imagefield.module after line 260 it works,
so there must be some problem with the passing by reference of $file (or me not getting php references). Thanks!
Comments
Comment #1
quicksketchThis is not a bug, any calls to module_invoke_all() are run through call_user_func_array(), which passes all arguments by value. See http://api.drupal.org/api/function/module_invoke_all/5
Comment #2
quicksketchComment #3
quicksketchThe Drupal 5 version is maintenance-only at this point, so this API function will not be changed. Perhaps a hook_form_alter() on the node form would be able to do the same thing.