Using colorbox with ckeditor and media (latest dev versions).
After choosing an image and submit. Colorbox throws

Notice: Undefined index: alt in theme_colorbox_image_formatter() (line 28 of /home/xxx/public_html/sites/all/modules/colorbox/
Notice: Undefined index: title in theme_colorbox_image_formatter() (line 29 of /home/xxx/public_html/sites/all/modules/colorbox/
Notice: Undefined index: alt in theme_colorbox_image_formatter() (line 28 of /home/xxx/public_html/sites/all/modules/colorbox/
Notice: Undefined index: title in theme_colorbox_image_formatter() (line 29 of /home/xxx/public_html/sites/all/modules/colorbox/
Notice: Undefined index: alt in theme_colorbox_image_formatter() (line 28 of /home/xxx/public_html/sites/all/modules/colorbox/
Notice: Undefined index: title in theme_colorbox_image_formatter() (line 29 of /home/xxx/public_html/sites/all/modules/colorbox/
Members fund testing for the Drupal project. Drupal Association Learn more


frjo’s picture

Status: Active » Postponed (maintainer needs more info)

I need a more detailed explanation on what modules you use to get Colorbox integration and how you insert the images. A link to an example site with this problem would work as well.

sgriffin’s picture

Colorbox 7.x-2.0+2-dev
CKEditor 7.x-1.12+2-dev
Media 7.x-2.0-unstable7+7-dev "Tried both versions.

CKeditor Add Media Button -> Library -> Choose a Photo -> Submit -> Error

Shows up for the formatting to embed the image in the nody body for ckeditor.

sgriffin’s picture

119.27 KB
frjo’s picture

Neither Media or CKEditor seems to have any Colorbox integration, did a quick search through there code.

Where and how does Colorbox get involved?

(I never use Wysiwyg myself so I have very little experience with it.)

sgriffin’s picture

I have another very similar site and can not duplicate the error after uninstalling/reinstalling/synching the modules etc.
The error only shows in media 7.2 and doesn't prevent the insert so this is just a strange annoyance. You can close this if you want.

frjo’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)
rwilson0429’s picture

I get the same error. I am using Media 7.x-2.x-dev, File Entity 7.x-2.x-dev and, core file field to store the images.

kaidjohnson’s picture

Assigned: Unassigned » kaidjohnson
Status: Closed (works as designed) » Needs review
834 bytes

I am running into this issue as well, along with an 'undefined index: title' in the media browser. Tracing back a bit, it appears that the $item variable that passes through the colorbox_field_formatter_view() is using the file_entity fields 'field_file_image_alt_text' and 'field_file_image_title_text' rather than 'alt' and 'title' indexes.

Here's a patch to alleviate the issue for those in need. There's likely a larger scope that could be addressed to resolve this issue. As a fan of Drupal colorbox and the Drupal media/file_entity project, I would like to see these two modules play well with each other.

frjo’s picture

I'm hesitant to commit this since it seems to be a Media module problem to me.

I could add checks to see if the alt and tile indexes are set. Please test the patch and report back it that fixes the errors.

kaidjohnson’s picture

I know what you mean - it's difficult to say where the responsibility for this compatibility issue lies. Your solution certainly prevents the errors from being thrown, however, I believe this simply fixes the affect rather than addressing the root of the issue. The patch I proposed (hesitantly) also only addresses the end result, and not really the root of the problem - it was more of a proposal to get ideas flowing.

Ultimately, this error is a result of the file_entity module, as it makes the Drupal file system fieldable. Naturally, images are given fields for their alt and title tags rather than metadata to handle rendering, and thus, the undefined index. I was getting one other error from colorbox about the file_entity changes (I believe it was along the lines of '$entity_type not defined' somewhere). Either way, I'm not noticing any functionality issues either from colorbox or from file_entity when using the colorbox format, so the errors appear superficial. If we can figure out a less specific way of handling images and their associated data to avoid the minor errors, I think it'll be worth committing to this module.

I'll continue playing with both file_entity and colorbox. I'll try to stay in touch to see if there's a more agnostic way of approaching file/image handling to avoid conflicts between these (and other) modules. Obviously, a fundamentally different way of handling files has a more global compatibility question that is probably not isolated to only colorbox.

frjo’s picture

If there is a nice and clean way to implement File entity compatibility in Colorbox I'm not against it. It seems to be a popular module

The Colorbox formatter is built to mimic the core image formatter as much as possible. This includes the use of 'alt' and 'title' indexes. What the core Image formatter does it check if these values are set and with my latest patch so does Colorbox formatter.

So if the File entity module makes some changes so it does work with the core image formatter it will most likely work with the Colorbox formatter also.

Rob C’s picture

Status: Needs review » Needs work

First: i figured lets post this here, because this is where i landed when searching a bit: (and not to hijack the issue, just to inform, review+info combo).

I have tested #8 and #9 with the latest file_entity from git and both seem to get the errors out of the way, but i also do not get a working popup with both patches. I've not installed media_colorbox, got media 2.x and file_entity 2.x installed, but can not get it to work. The thumbnail loads fine, but links to the file style, the popup is never loaded, or loaded without an image.

Without patches media_colorbox Works for uid 1, read about new file_entity permissions below.

The media and file_entity 2.x branches are under heavy development and i would love to see more modules support the file_entity module, including colorbox, but i'm not sure what the best way forward is. Both the Colorbox and Media colorbox modules (almost) seem to offer the same end-result, but configuration is not the same.

From what i've seen the media_colorbox module does work, but the new file_entity permissions are not implemented in media_colorbox yet, a patch does exist, read below. The file_entity module is mostly complete from what i've read, yes some criticals still exist and more major features have yet to be implemented, but the core of the module now looks stable, works kinda nice, and already has motivated a couple interesting projects, be sure to filter for file (and / or file entity) on the modules page sometime.

Media colorbox creates a new view mode, called 'Media Colorbox' you can configure via the admin/structure/file-types/manage/image/file-display page. You can set almost the same options as the colorbox module provides on the view mode config page, but now on the node field display config page.

On admin/structure/types/manage/gallery/display (for example) you then can set the 'Format' to 'Media colorbox' and select 2 view modes for thumbnail and popup and configure a gallery setting - or not.

Currently the admin/structure/file-types/manage/image/file-display page shows the following errors: (without patches)

    Notice: Undefined index: entity_type in colorbox_field_formatter_settings_form() (line 357 of colorbox/colorbox.module).
    Notice: Use of undefined constant field_ui_formatter_options - assumed 'field_ui_formatter_options' in media_colorbox_field_formatter_settings_form() (line 145 of media_colorbox/media_colorbox.module).

View modes in 2.x might need some work, but take a look at this while your at it:

A related issue has been reported for the media_colorbox module here: #1888198: Colorbox does not work in WYSIWYG after updating to Media 2.0-unstable7 and Media Colorbox 1.0-rc3 and i've found: #1658742: This content failed to load.

Previously the only way to overcome the last issue was to set 'Bypass file access control' on the permissions page for all roles, but that's not something i would advice.

#1730730: Use file_access() instead of file_entity_access() ( Comment 6 ) is now RTBC and fixes the new permissions for media_colorbox. I'm using this on my test site and looks pretty good. That's all current git versions for file_entity 2.x/colorbox 2.x/media 2.x/media_colorbox 1.x + the patch from #1730730. (The colorbox module is a dependency for media_colorbox.) So this might be worth checking out?

And i agree with both #8 and #9, but i guess the media_colorbox module actually should be called file_entity_colorbox. You do not require the media module to install it, that might be where the mixup started. (might be wrong here, but check the .info file, just didn't test it on a box without media, because i always use media).

In my mind colorbox should focus on what it does best: Colorbox. Leave the other features to other modules - or implement something that works great, maybe based on previous work/existing projects like media_colorbox - once it has matured enough. While the alt/title attributes are a must-have, yeah it's possible to implement it all into colorbox, for the long-term that would also make a lot of sense i guess, because the file_entity module is here to stay.

Hope this helps.

ParisLiakos’s picture

Category: support » bug

this is due to this commit #1876392: Leverage Image field formatters too
now colorbox formatter is available under file display formatters
here is a similar fix from photoswipe that should be applied here

NaX’s picture

Patch #9 worked for me and I think it is a reasonable solution regardless of what is happening upstream with other projects.

frjo’s picture

Assigned: kaidjohnson » Unassigned
Status: Needs work » Fixed

Patch #9 committed to 7.2-dev.

Status: Fixed » Closed (fixed)

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