• English
  • Русский

Media Gallery + Colorbox - flipped photos in colorbox

As we know, in Media Gallery photo in colorbox opens on a separate page when you click on it. Therefore many readers ask: how to make photo opens in same colorbox window when you click?

And here's the solution:

In file sites/all/modules/media_gallery/media_gallery.theme.inc finddunction template_preprocess_media_gallery_media_item_thumbnail (aproximately 108 line) construction

  1. if ($lightbox) { $element['file']['#attached']['js'][] = drupal_get_path('module', 'media_gallery') . '/colorbox-display.js';
  2. $element['file']['#attached']['library'][] = array('media_gallery', 'colorbox'); }

replace by this code:

  1. if ($lightbox) { $element['file']['#attached']['js'][] = drupal_get_path('module', 'media_gallery') . '/colorbox-display.js';
  2. $element['file']['#attached']['js'][] = drupal_get_path('module', 'media_gallery') . '/colorbox-behavior.js';

Then create in module's folder file colorbox-behavior.js and place this code:

  1.    (function ($) {
  2.     Drupal.behaviors.initColorboxDefaultStyle = {
  3.       attach: function (context, settings) {
  4.         $(document).bind('cbox_complete', function () {
  5.         $('.lightbox-stack .gallery-thumb-inner a').click(function(e) {
  6.             e.preventDefault();
  7.             $.colorbox.next();
  8.           });
  9.         });
  10.       }
  11.     };
  12.      
  13.     })(jQuery);
Рубрика: 

Comments

Add new comment