drupal 7 beta 3.
I get
Notice: Undefined index: fid in theme_colorbox_image_formatter() (line 63 of C:\wamp\www\drupalcase\sites\all\modules\colorbox\colorbox.theme.inc).

sometimes on node view. It the notice does not show, it does if I refresh the page.

CommentFileSizeAuthor
#6 colorbox_view_formater.jpg441.17 KBJohnz86
#6 error_std.jpg486.51 KBJohnz86

Comments

pieterdc’s picture

I got the same kind of bug, but mine says:
Notice: Undefined property: stdClass::$title in theme_colorbox_image_formatter() (line 39 of /www/sites/all/modules/colorbox/colorbox.theme.inc).

with yesterdays' Drupal 7 dev version.

frjo’s picture

With Drupal 7 RC 1 and Colorbox 7-dev I can't reproduce this in my quick testing today.

I'm using a normal image field and has set Colorbox as the formatter for the field. What is your setup?

pieterdc’s picture

I also use Colorbox 7-dev

I have added an image field to a user.
When viewing the user; $node->title doesn't exist as it isn't a node I'm viewing.

frjo’s picture

Status: Active » Needs review

Committed a fix that checks if node is not empty to theme_colorbox_image_formatter(). It's a quick fix until I get in a proper solution to make Colorbox work in all places you now can add fields.

The original error about fid I'm uncertain about. Should not a fields always have a fid?

pieterdc’s picture

I guess a file field - like an image field - should always have a fid.

Maybe @thsyd02 can give more information about the error.

Johnz86’s picture

Assigned: Unassigned » Johnz86
StatusFileSize
new486.51 KB
new441.17 KB

I have the same problem.. I have installed the current new version of Drupa 7 RC 2. I can create an image in colorbox, in the image field, by adjusting manage display field. That works fine without problems and no errors. But when i create a View and add colorbox formater, it produces this error. I can still see the image loaded in colorbox, but the red error remains.

thsyd02’s picture

@PeterDC; sorry I have been away. Now with a fresh install of Drupal 7 RC2 and the colorbox 7.x-1.x-dev from dec 08th, I cannot reproduce the issue. Sorry. I have removed the installation I used when I created the issue, so no way to reproduce.
using the above with default settings and adding an image field with colorbox display to the default article content type works perfectly.
Using XAMPP on a windows 7 home premium 64 bit system.

pieterdc’s picture

Status: Needs review » Needs work

Thanks for the extra info.

But adding an image field to a user account / profile, being a non node entity, still gives the PHP notice.

Johnz86’s picture

I tried it again, the error is not produced, when the colorbox is invoked directly from the default node. When you create any views with colorbox this error is invoked.

pieterdc’s picture

I'm also using it in a view, you got that right ;-)

Johnz86’s picture

I partialy solved this problem, when i overwrote this line of code in colorbox.theme.inc
elseif (!empty($node)) {
$image['title'] = $node->title;
}
with this:

elseif (!empty($node->title)) {
$image['title'] = $node->title;
}
the whole if else statetment is for assigning a string to image[title]. So in the end the image[title] will be probably empty. I dont understand the internal workings of the module, what other effects will it have, but this solved the problem for me. The colorbox dosent make any errors.

avo_liao’s picture

Thank you Johnz86, that solved the problem.

Jackinloadup’s picture

Thanks fixed my error as well

frjo’s picture

Assigned: Johnz86 » frjo
Status: Needs work » Needs review

The suggestion from Johnz86 in #12 is now committed to 7-dev, thanks!

frjo’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

adrinux’s picture

Status: Closed (fixed) » Active

So changing line 63 of colorbox.theme.inc from:

      $gallery_id = $nid . '-' . $field['fid'];

to:

      $gallery_id = isset($field['fid']) ? $nid . '-' . $field['fid'] : $nid . '-' .'fid';

Is how I just corrected the error.

frjo’s picture

Status: Active » Fixed

@adrinux, the bug is that it is $item that has fid and not $field. This has been fixed in 7-dev already and vill be part of the next release.

Status: Fixed » Closed (fixed)

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