Hi,
in the new version not work Auto image handling. Shadowbox works only if I add manually rel="shadowbox". I tried to disable the feature and enable it again. Someone has the same problem ?

Comments

EricD’s picture

Yes, I'm having the same problem. The documentation to get this to work within Drupal is VERY poorly written.
I wish that I could figure out how to get it to work in Drupal 6.X... then I would re-write the instructions for those having the same issues as I. Too bad, it's seems like it might be a nice module. The "example" works great, but anything else just simply doesn't work.
I'm certain it has to do with the (rel="shadowbox") link but the instructions to use Shadowbox.setup are not clear.

If anyone is willing to help me, I'd be willing to re-write a set of instructions that are more specific than the "INSTALL.txt", "README.txt" and "TROUBLESHOOTING.txt" that come with the module.

shp’s picture

The same problem... This feature is handled by script shadowbox_auto.js in the module's directory (script uses jQuery). I'v put shadowbox_auto.js code directly at the page end & drop original script - no changes. Then I tried

<script type="text/javascript">
      document.getElementById('mylink').attr('rel', 'shadowbox');
</script>

at the page end - the same result.

Clean JS:

<script type="text/javascript">
      document.getElementById('mylink').setAttribute('rel', 'shadowbox');
</script>

- works!

So, it seems that there are some problems with jQuery method attr().

djs_core’s picture

Ok,
and so we have a solution for normal users? ;) What to change in the module to make it functional? I tried to change shadowbox_auto.js according to your information:

// $Id: shadowbox_auto.js,v 1.1.4.4.2.1 2009/08/21 16:27:38 psynaptic Exp $

if (Drupal.jsEnabled) {
  $(document).ready(function() {
    var settings = Drupal.settings.shadowbox;
    if (settings.auto_enable_all_images == 1) {
      var images = 'a[href$=jpg][rel=""], a[href$=png][rel=""], a[href$=gif][rel=""], a[href$=jpeg][rel=""], a[href$=bmp][rel=""], a[href$=JPG][rel=""], a[href$=PNG][rel=""], a[href$=GIF][rel=""], a[href$=JPEG][rel=""], a[href$=BMP][rel=""]';
      $(images).each(function() {
        if (settings.auto_gallery == 1) {
          $(this).setAttribute('rel', 'shadowbox[gallery]'); // <--here
        }
        else {
          $(this).setAttribute('rel', 'shadowbox'); // <--here
        };
      });
    };
  });
}

But no change...

shp’s picture

It seems that the problem is with ready(). So, the dummy solution is not to use it (shadowbox_auto_dummy.js):

if (Drupal.jsEnabled) {
  //$(document).ready(function() {    // <--comment this str
    var settings = Drupal.settings.shadowbox;
    if (settings.auto_enable_all_images == 1) {
      var images = 'a[href$=jpg][rel=""], a[href$=png][rel=""], a[href$=gif][rel=""], a[href$=jpeg][rel=""], a[href$=bmp][rel=""], a[href$=JPG][rel=""], a[href$=PNG][rel=""], a[href$=GIF][rel=""], a[href$=JPEG][rel=""], a[href$=BMP][rel=""]';
      $(images).each(function() {
        if (settings.auto_gallery == 1) {
          $(this).attr('rel', 'shadowbox[gallery]');
        }
        else {
          $(this).attr('rel', 'shadowbox');
        };
      });
    };
  //});   // <--comment this str
}

!! But it will work only after the links appear in the DOM. So, you should execute this code at the page-end. The easiest way is to modify your page.tpl.php:

  ....
    <script type="text/javascript" src="/sites/all/modules/shadowbox/shadowbox_auto_dummy.js"></script>
  </body>
  ....

! But this solution is temporary and dummy ! The developer should examine this problem and use hook_footer() better to insert js (or rewrite his js-script).

djs_core’s picture

Thank you very much! Dummy solution work ;) I hope that the problem the authors formally resolved as quickly ...

psynaptic’s picture

Status: Active » Fixed

Thanks guys:

http://drupal.org/cvs?commit=264304

Committed to DRUPAL-6--3

Status: Fixed » Closed (fixed)

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