[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/imagecache/ -> imagecache.js (source)

   1  /*global Drupal,jQuery */
   2  
   3  (function($) {
   4    "use strict";
   5  
   6    Drupal.imagecache = {
   7      /**
   8       * Remove the files directory prefix from a path.
   9       */
  10      stripFileDirectory: function(path) {
  11        var filePath = Drupal.settings.imagecache.filesDirectory;
  12        if (path.substr(0, filePath.length + 1) === filePath + '/') {
  13          path = path.substr(filePath.length + 1);
  14        }
  15        return path;
  16      },
  17  
  18      createUrl: function(preset, path) {
  19        var stripped = this.stripFileDirectory(path);
  20        // If the preset is invalid, return the path to the original image.
  21        if ($.inArray(preset, Drupal.settings.imagecache.presets) !== -1) {
  22          return Drupal.settings.imagecache.filesUrl + '/imagecache/' + preset + '/' + stripped;
  23        }
  24        return Drupal.settings.imagecache.filesUrl + '/' + stripped;
  25      }
  26    };
  27  
  28    Drupal.theme.prototype.imagecache = function(preset, path, alt, title, attributes) {
  29      var image;
  30      image = new Image();
  31  
  32      image.onload = function() {
  33        $(this).attr({
  34          width: $(image).width(),
  35          height: $(image).height()
  36        });
  37      };
  38  
  39      image.src = Drupal.imagecache.createUrl(preset, path);
  40      image = $.extend(image, {
  41        title: title,
  42        alt: alt
  43      }, attributes);
  44  
  45      return image;
  46    };
  47  })(jQuery);
  48  
  49  /*jslint browser: true, onevar: true, undef: true */
  50  


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7