I'm using imagefield_crop with the field_collection module (http://drupal.org/project/field_collection) and I'm actually getting the following three errors on each image attached to the node. These errors come up when I save the node even if I haven't modified (added or removed) any of the images.

Notice: Undefined property: FieldCollectionItemEntity::$language in _imagefield_crop_entity_presave() (line 264 of C:\path\to\my\sites\all\modules\imagefield_crop\imagefield_crop.module).
Notice: Undefined index: in _imagefield_crop_entity_presave() (line 264 of C:\path\to\my\sites\all\modules\imagefield_crop\imagefield_crop.module).
Warning: Invalid argument supplied for foreach() in _imagefield_crop_entity_presave() (line 264 of C:\path\to\my\sites\all\modules\imagefield_crop\imagefield_crop.module).

I'm posting this issue here instead of in field_collection because I saw a similar thread (with a patch) for imagefield_crop. I tried the patch but it didn't fix the problem.

Comments

wiifm’s picture

Version: 7.x-2.0 » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new2.46 KB

Here is a patch for 1.x-dev that addresses the first issue. It is caused by the fact that there is no language property in the fieldCollectionItem object.

Tested on regular image fields, and image fields in a field collection.

joetsuihk’s picture

@wiifm can you take a look if http://drupalcode.org/project/imagefield_crop.git/commit/3e680ca already fixed the problem?

It is actually from http://drupal.org/node/1415382#comment-6940942

wiifm’s picture

Hi @joetsuihk I am running the latest --dev (from only a day ago), which includes that patch. This patch will only apply on the latest --dev too.

joetsuihk’s picture

Status: Needs review » Closed (fixed)
extexan’s picture

Just a heads-up... I subsequently posted this as an issue on field_collections (http://drupal.org/node/1889208) after seeing another similar issue.

Seems like this should be fixed at the source instead of patching *this* module to handle the problem.

joetsuihk’s picture

Thanks for the heads up! I am now also following that issue and once that is fixed on fieldcollection, seems we can take out those code. But for now, leave those code in so everyone is happy?

WebmistressM’s picture

Im having this same problem and #4 did not change the problem. Please note that this may be a slightly diffrent situation as Iam not using the Field Collection module. Just trying to create a way for people to crop the pic they attempt to upload as a profile2 avatar. Is it possible that using an image crop field on a profile2 field (vs a content field) is the problem?

joetsuihk’s picture

re #7 from http://drupal.org/node/1358474#comment-6083610, seems latest dev should fixed one problem.

If it is not the case, please create a new issue targeting profile2 field

extexan’s picture

I see that the version I originally posted this under got changed in the first comment. Is there a similar fix for the 7.x-2.0 or 7.x-2.x-dev version?

extexan’s picture

This fixed version 7x-2.0 for me (sorry I couldn't put it in a proper patch file). This is in the _imagefield_crop_entity_presave() function in imagefield_crop.module (starting at line 256 in my version)...

    if (!isset($entity->{$field_name})) {
      continue;
    }
    // Added the following line...
    $entity->language = (isset($entity->language) ? $entity->language : LANGUAGE_NONE);
    foreach ($entity->{$field_name}[$entity->language] as $delta => $imagefield) {
      $file = file_load($imagefield['fid']);
      $info = image_get_info($file->uri);
      if (is_array($info)) {
        $entity->{$field_name}[$entity->language][$delta]['width'] = $info['width'];
        $entity->{$field_name}[$entity->language][$delta]['height'] = $info['height'];
      }
    }

Hope this helps.

joetsuihk’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Closed (fixed) » Needs review