Hi All,

This is a great module.. I was just wondering if it would be possible to integrate this with colorbox? This feature would be awesome on windows that open via CB.

Tks.

Comments

radimklaska’s picture

Version: 6.x-1.0 » 7.x-1.x-dev

I'm changing version because original request is really old and main focus should be on D7 now.

Also I should point out, that http://drupal.org/project/vtcommerce_image has similar functionality, but makes lots of assumptions.

anybody’s picture

Priority: Major » Normal
Issue summary: View changes

I have the same requirements and will try to create a patch right now. Anyway this is not major, but it's sad that there has not been an answer for over a year.

anybody’s picture

This is simple and robust to add.

Here are my changes:
js/cloud_zoom.js:

(function ($) {
Drupal.behaviors.cloudZoom = {
  attach: function (context, settings) {
    items = $('.cloud-zoom:not(cloud-zoom-processed), .cloud-zoom-gallery:not(cloud-zoom-processed)', context);
    if (items.length) {
      items.addClass('cloud-zoom-processed').CloudZoom();
      items.parent().css('float', 'left');

// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      // Colorbox integration
      items.each(function() {
        if ($(this).hasClass('colorbox')) {
          // Add click event to wrapper (else mouse trap blocks it)
          // But only if colorbox was initialized for this field.
          var $item = $(this);
          $item.parent().click(function() {
            $item.colorbox(jQuery.extend({open: true}, settings.colorbox));
            return false;
          });
        }
      });
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    }
  }
};
})(jQuery);

cloud_zoom.module
Append to function cloud_zoom_settings_info():

if (module_exists('colorbox')) {
    $settings['colorbox'] = array(
      'title' => t('Open details in Colorbox'),
      'id' => FALSE,
      'description' => t('Show the image in colorbox on click (requires the colorbox.module)'),
      'default_value' => FALSE,
      'form_type' => 'checkbox',
      'fieldset' => 'zoom_style_fieldset',
    );
  }
/**
 * Theme handler for the cloud_zoom (no gallery)
 */
function theme_cloud_zoom_image($variables) {
  // Add the Cloud Zoom Library
  drupal_add_library('cloud_zoom', 'cloud-zoom');

  $item = $variables['item'];

  $slide = cloud_zoom_get_img_tag($variables['slide_style'], $item);

  // Build a Zoomed In URL path
  $zoomed = $variables['zoom_style'] ? image_style_url($variables['zoom_style'], $item['uri']) : file_create_url($item['uri']);
  $rel = cloud_zoom_get_rel_string($variables);

// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  $attributes = array('class' => array('cloud-zoom'), 'rel' => $rel);
  // Use colorbox?
  if (!empty($variables['colorbox']) && module_exists('colorbox')) {
    $attributes['classes'][] = 'colorbox';
    $attributes['title'] = $item['title'];
  }
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  // Return the preview image as a link to the larger image with a cloud-zoom CSS class
  return l($slide, $zoomed, array('html' => TRUE, 'attributes' => $attributes));
}

If the module maintainer is interested, I can provide a patch.
The change is tested and works great.

anybody’s picture

I've attached the patched module to have a look and test it quickly.

romazh’s picture

after last div in body.tpl.php

(function ($, Drupal) { $(".cloud-zoom-container").click(function() { $(this).find("a").colorbox({open: true, rel:'cloud-zoom-gallery'}); }); })(jQuery, Drupal);
anybody’s picture

Well that's not a clean idea (from my point of view) to add this to body.tpl. At lease you should create a module for that.

Anyway it may work. The main question is: Should the colorbox integration become a feature of this module or not?
My solution provides a clean checkbox for each cloudzoom field.

vensires’s picture

Actually, I don't believe there is a "should" or "must" here, though I believe that an integration with a *box module would be very handy and wouldn't add a lot of extra weight to Drupal.

What I can see from my point of view as a web developer though is that - at least in Greece - more and more clients building their e-shop are asking for both a CloudZoom and a Lightbox/Colorbox integration. Taking into account that Colorbox at this time of writing has 237,725 sites actively using it, whereas Lightbox2 has 134,288 sites actively using it, I think that Colorbox module is the way to go and stick to it. Besides, Colorbox has already an on-going Drupal 8.x version.

vinmassaro’s picture

Status: Active » Needs review
StatusFileSize
new3.26 KB

Here is a patch of Anybody's work in #4. I had to change $attributes['classes'] to $attributes['class'] for it to add the 'colorbox' class properly. I've tested this simple patch and it works well.

I removed all of the syntax changes so that this patch isolates just the changes to add colorbox support. The syntax changes could be introduced in a separate patch in another issue. Please test, thanks!

tarasikarius’s picture

#5 worked for me well, the only thing is I add it to my theme's js file.

msti’s picture

It looks like this feature is not a priority for the maintainer.

Here is the patched module using the patch from #8 plus another improvement (colorbox for cloud zoom gallery).

https://github.com/msti/cloud-zoom-drupal

anybody’s picture

Confirming Patch from #8 is RTBC. @msti, can you also confirm that?
This may help the maintainer to take this forward.

msti’s picture

StatusFileSize
new2.79 KB

I thought the patch was already confirmed.

#8 is confirmed.
And this patch also adds colorbox support to the gallery cloud zoom.

charlysole’s picture

After applying the patch i'm getting this notice
Notice: Undefined index: colorbox en cloud_zoom_field_formatter_view() (line 449 at .../cloud_zoom/cloud_zoom.module).
No zoom effect anymore, but clicking the image, colorbox opens
Any ideas?

  • dakku committed ba303a1 on 7.x-1.x authored by msti
    Issue #1269026 by msti: Colorbox integration
    
dakku’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

vinmassaro’s picture

The committed patch breaks the non-gallery version of Cloud Zoom because the default $attributes array was dropped. I've posted a patch to fix this here #2930549: Recent colorbox integration breaks Cloud Zoom.