Closed (fixed)
Project:
Image Field Random
Version:
7.x-1.0-beta1
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
30 Mar 2016 at 00:00 UTC
Updated:
2 Jun 2016 at 17:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
miechiel commentedI created a patch that could solve this issue. In the old version the module was using the hook_field_attach_submit() which means that the a form with images must be submitted. I changed this to work with the hook_entity_presave().
On a clean Drupal install with profile2 when a user is being created the profile2 random image fields are being created as well.
I also made sure the files are being copied to the proper directory so that a user can not (per accident) delete an image from the random image field folder.
Comment #3
drusite commentedI applied this patch and there are some errors
Notice: Undefined variable: type in function image_field_random_field_attach_submit() (string 55 in file /sites/all/modules/image_field_random/image_field_random.module).
Notice: Undefined variable: type in function image_field_random_field_attach_submit() (string 59 in file /sites/all/modules/image_field_random/image_field_random.module).
They are related to $entity_info = entity_get_info($type); and $field_instances_info = field_info_instances($type, $type);
Is it normal that there are two $type ?
Comment #4
drusite commentedWhen a node is submitted, these errors appear (Advanced Forum content, maybe it is true for all content types).
Comment #5
danielphenry commentedSo I think the new hooks are probably ok.
But by why did you duplicate the file instead of just adding a file usage like the code previously did? Duplicating the file wastes server space and is less performant than just adding an entry to the file usage table.
Did you have a good reason for this change? I'm open to hearing it but it's got to justify the above mentioned issues. I could see this as an optional setting in case someone wants to use image cache_actions on the files or something like that but certainly not the default behavior.
Comment #7
danielphenry commentedI took a hard look at your patch and most of the changes are unnecessary or a step backwards.
I've discarded all of these changes.
I have applied these changes:
This fix is checked into the 7.x-1.x. Someone try it out and confirm it works before I spin up a bata2 release.
Comment #8
drusite commentedWhere is 7.x-1.x version? I verified https://www.drupal.org/node/1913234/release and it doesn't exist there.
Comment #9
danielphenry commentedSorry never rolled out a release you would just have to check out the branch directly from the git repo: https://www.drupal.org/project/image_field_random/git-instructions
I'll try to get a dev release rolled up.
Comment #10
danielphenry commentedThe latest dev release now has this patch in it. Please let me know if it works out for you.
Comment #11
danielphenry commentedclosing properly