Notice: Undefined index: alt in uc_product_get_picture() (line 1840 of /path/to/drupal/sites/all/modules/contrib/ubercart/uc_product/uc_product.module).
Notice: Undefined index: title in uc_product_get_picture() (line 1840 of /path/to/drupal/sites/all/modules/contrib/ubercart/uc_product/uc_product.module).

The alt and title attributes are nested within the 'data' array of the returned $image

Comments

longwave’s picture

Status: Active » Fixed

Confirmed, tested and committed. Thanks!

tr’s picture

We keep going back and forth on this. See the first few results at http://drupal.org/project/issues/ubercart?text=%24image['data']['alt']&status=All&priorities=All&categories=All&version=All&component=All for some history of the issue. Perhaps it has something to do with imagefield version or some other unknown factor, but experience shows that someone is going to complain about this fix and request the exact opposite.

longwave’s picture

Status: Fixed » Needs work

As far as I can see in imagefield itself, this change was made three years ago:
http://drupalcode.org/project/imagefield.git/commitdiff/f01da49
http://drupalcode.org/project/imagefield.git/commitdiff/e917e80

But perhaps we should do something like this?

      $metadata = isset($image['data']) ? $image['data'] : $image;
      $img = theme('imagecache', $format, $path, $metadata['alt'], $metadata['title']);
longwave’s picture

or maybe

      $alt = isset($image['data']['alt']) ? $image['data']['alt'] : $image['alt'];
      $title = isset($image['data']['title']) ? $image['data']['title'] : $image['title'];
      $img = theme('imagecache', $format, $path, $alt, $title);
tr’s picture

Status: Needs work » Fixed

Let's just leave it the way it is for now, with the original patch committed. Looking at http://drupal.org/node/742084#comment-3595762 it sounds like Lyle intended to make it look like $image['data']['alt'], $image['data']['title'], but I don't see a record of that commit. So I suspect part of the confusion is that the code was never changed to reflect the discussion in the issue. If it has been that way for three years then we shouldn't have to cover for the old, unsupported, unpublished version of Imagefield that uses the old style.

longwave’s picture

uc_product_table() had a similar issue so I changed that code as well.

http://drupalcode.org/project/ubercart.git/commitdiff/045bbd7

longwave’s picture

Lyle's commit was http://drupalcode.org/project/ubercart.git/commitdiff/31e9423 but didn't change all instances, so (fingers crossed) this issue is solved once and for all.

tr’s picture

Ah, that explains why I didn't find it - I was tracing line 1840, which didn't get fixed. It also explains why various people in those issues were seeing different things - some were evidently looking at output of uc_product_get_picture(), which was not fixed, and some were evidently looking at the output of theme_uc_product_image(), which *was* fixed.

grafikchaos’s picture

Looks like I missed an earlier call to the $image['alt'] and $image['title'] that I originally posted. I've attached an additional patch for the one I missed

Edit: OOPS! I missed longwave's comment in #6, these are identical patches so just use that one and I wish I could delete this comment.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

prettied up my original post by adding code tags around the php notice messages