hello,
the onclick event to the next photo is not working if you use "file field" instead of "image field" for your gallery

used modules:
- media colorbox (7.x-1.0-rc1)
- media (7.x-2.0-unstable3+41-dev)
- entity (7.x-1.0-rc1+45-dev)

Comments

kmadel’s picture

I am using 'file field' and the Colorbox next/prev buttons work for me, but I have not tried to use the onclick event to the next photo. How is that supposed to work, and do you have custom code or just what Colorbox includes?

kmadel’s picture

Category: bug » feature

This is not a bug because Media Colorbox will always display an HTML page as the content of the Colorbox overlay, never just an image. The Colorbox click photo functionality only works when just an image, by itself, is loaded in the Colorbox and this will never be the case for Media Colorbox output (at least not unless a new feature is added). The idea is that you may want to display a number of fields that are part of your File entity Image type (like Geolocation or other Exif data). Media Colorbox gives you the flexibility to display whatever fields you may have added to you File entity types (to include the Image type) at the expense of not handling images as standalone images.
This issue could become a feature request for adding formatter settings to tell Media Colorbox to ignore the Colorbox view mode for the Image type and instead display the Image type File entity as just an image. Or add custom JavaScript to wrap the actual image of the view mode output and attach the Colorbox next event to its onclick event.

murz’s picture

Yes, this is feature request, but it is very needed. Can you provide some hack or workaround for this?
Here is example how to do this: http://stackoverflow.com/questions/11515234/how-to-make-colorbox-inline-...
but it isn't work for me, I try to search more.

murz’s picture

It works if I add manually in html code adds via firebug to div.file-image function onclick='jQuery.colorbox.next()', so for solve this issue we must add onclick event to each image file type.

murz’s picture

Quick ugly hack for solve this issue is to replace in file media_colorbox.pages.inc string

  print drupal_render(file_view($file, $view_mode, $langcode));

to:

  $output = drupal_render(file_view($file, $view_mode, $langcode));
  $output = str_replace('<div class="content"','<div style="cursor: pointer" onclick="jQuery.colorbox.next()" class="content"',$output);
  print $output;

It works for me very well for images.

murz’s picture

And here is workaround for video (youtube) files, for disabling click-to-play on it:

  if(strpos($file->filemime,'video')===false) 
    $output = str_replace('<div class="content"','<div style="cursor: pointer" onclick="jQuery.colorbox.next()" class="content"',$output);
kmadel’s picture

Version: 7.x-1.0-rc1 » 7.x-1.0-rc2
Status: Active » Closed (fixed)

Fixed with rc2 release.

murz’s picture

Thanks for fixing, but in rc2 missed feature "cursor: pointer" on image area, so not each user understand that he can click on image :)