Jump to content

Recommended Posts

Posted

Just discovered something weird with the Thumbnails module http://modules.processwire.com/modules/fieldtype-crop-image/

I'm using PW 2.3.2, Thumbnails module v1.0.3

Basically, I have this code in my template:

<img src="<?php echo $page->thumbnail->getThumb('department-thumb'); ?>" >

and in my <head> I have this code:

<?php foreach($config->scripts as $file) echo '<script src="'.$file.'"></script>'; ?>	

I populate $config->scripts by doing the following in my init.php file:

   $scripts = array(
       'modernizr' => $url.'modernizr.js'
      ,'jquery' => $url.'jquery.js'
      ,'masonry' => $url.'jquery.masonry.min.js'
      ,'fancybox' => $url.'jquery.fancybox.js'
      //,'bootstrap' => $url.'bootstrap.js'
      //,'main-js' => $url.'main.js'
      ,'responsive-slides' => $url.'responsiveslides.min.js'
      ,'main' => $url.'script.js'
      ,'placeholder' => $url.'placeholderfix.js'
      );
   
   foreach($scripts as $key => $file)
      $config->scripts->add($file);

Actually, you can recreate the issue without populating $config->scripts with your custom scripts just as long as jQuery Fancybox Plugin is activated.

To recreate the issue, use this inside your template:

<?php

$output = '<img src="' . $page->thumbnail->getThumb('thumbnail') . '">

?><!doctype html>
<head>
<?php foreach($config->scripts as $file) echo '<script src="'.$file.'"></script>'; ?>	
</head>
<body>
<?php echo $output; ?>
</body>
</html>

In your <head> you should see something along the lines of:

<script src="/wire/modules/Jquery/JqueryFancybox/JqueryFancybox.js?v=126"></script>

Which we don't want loading in there.

But, if you do the "getThumb()" call inside the <body>, meaning you do it after the scripts/css has been loaded, then JqueryFancybox of course won't be loaded.

Posted

Just replied to another message from you that is almost the same as this. :) But I think this message maybe points to the Thumbnails module as being the one that is calling upon JqueryFancyBox. Probably the Thumbnails module should only call upon JqueryFancyBox when in admin/page editing mode, rather than in API usage. 

Posted

Hmm.. not sure where it comes. Probably getThumb inits inputfieldImage which then populates that fancyscript. I took a quick look and couldn't figure out where it comes actually.

As a quick fix you could remove that script before looping your scripts (not a clean solution in a long run, I agree). Anyone else has a clue how to prevent fancymodal here?

Posted

Thanks Ryan. Yup, you're right it's *sort of* coming from the Thumbnails module because the module is extending FieldtypeImage. As @apeisa as getThumb() inits InputfieldImage via call to _getInputFieldInstance()  and InputfieldImage has this in it's init() function:

$this->modules->get("JqueryFancybox"); 
  • Like 1
Posted

Okay I understand now. I think I can safely move the call to JqueryFancybox to the render() method, which should fix this issue.

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...