This module encounters a fatal error when croppable image fields are included in a profile2 entity: http://drupal.org/project/profile2
The problem has to do with the way $instance is selected around line 499 of imagefield_crop.module.
$instance = $form_state['field'][$element['#field_name']][$element['#language']]['instance'];
$profile2 puts that data in a different location in the $form_state array
$profile2_instance = $form_state['field']['#parents']['profile_business']['#fields'][$element['#field_name']][$element['#language']]['instance'];
Also, there's another error when profile2 forms are displayed programmatically via drupal_get_form()/render, there's an error when photos are uploaded. Basically, the user.pages.inc file is not automatically included. So around that same line where the instance is selected doing the following fixed it:
include_once drupal_get_path('module', 'user') . '/user.pages.inc';
$instance = $form_state['field'][$element['#field_name']][$element['#language']]['instance'];
There has no be some more intelligent way to make sure the required includes are loaded when imagefield crop does its ajax call.
I don't know technically who would be best to fix this, so I'm going to post about it in both issue queues.
Thanks!
-Brent
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 0001-Fixing-field-instance-issue.patch | 936 bytes | pwaterz |
Comments
Comment #1
bdu commentedThe profile2 issue for this is #1178370: Notice: Undefined index: field_photo in imagefield_crop_widget_process(). According to the profile2 maintainer this is probably due to imagefield_crop not being able to cope with embedded field forms.
Comment #2
thetoast commentedSame issue......I just wanted to add that I tested the image cropper on the user entity and taxonomy entity and it worked fine on both, and I also tested it with a custom entity (creating an entity using the eck module) and it also worked fine with that. So I'm just wondering, is it this modules issue why that error appears with profile2? As for adding the include file for user pages, I suppose if you're doing stuff like drupal_get_form then it shouldn't be a problem to add it yourself :-) ...... it's not uncommon to have to do stuff like that when you're writing custom code for drupal, for example, I've had to add it when calling drupal_get_form on the user password reminder form.
Comment #3
pwaterz commentedHere is a patch that fixes this :) Enjoy!
Comment #4
pwaterz commentedComment #5
ridgek commentedThanks, pwaterz!!!
Comment #6
calefilm commentedThanks for patch Pwaterz :)
Comment #7
fraweg commented#3 works perfect!
Thanks so much Pwaterz!
Comment #8
mattsmith3 commented#3 works great here too.
Comment #9
DeFr commentedDo note that a fix for this issue was commited to the 7.x-2.x branch (after the 7.x-2.0 release though) , in http://drupalcode.org/project/imagefield_crop.git/commit/a0e80f2ef8f611a... . The patch applies to the 7.x-1.0 release (with a kinda huge offset), and seems to fix the problem for me.
Comment #10
scotwith1tFixed the problem for me with 1.0. Can we get this committed? This makes this work on any image field on other types of entities, like Profile2.
Comment #11
citricguy commentedPossible duplicate: http://drupal.org/node/1369836
Comment #12
pav commented#3 works great. thanks
Comment #13
joetsuihk commentedcommited, thanks all!
http://drupalcode.org/project/imagefield_crop.git/commit/735336f
Comment #14
GaneshKumar commentedThanks pwaterz for your patch.