I want to implement this famous image preloader in my theme :
http://net.tutsplus.com/tutorials/javascript-ajax/how-to-create-an-aweso...

I want all (big) images to have a fading-in and 'loading.gif' before they appear

This is what I did so far:
I'm putting the javascript in the info-file like this:
scripts[] = scripts/jquery.preloader.js

I'm also putting the loading.gif in the image folder of my theme

I just need to call the javascript.
In html it's simply this little script in the </head> section :
<script type="text/javascript">$(function(){$("#gallery").preloader();});</script>

How do I handle this last step in drupal 7 ?

Comments

Anonymous’s picture

You can use drupal_add_js (http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_ad...) and set the 'type' to 'inline'.

drupaltronic’s picture

Could you give an example on how to to this.

Anonymous’s picture

Sure, if you look at this page: http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_ad... you'll find a lot of examples, including the one you're trying to implement