demos/Collage/fabric.js
function (url, callback, options) {
      return fabric.util.loadImage(url, function(img) {
        this.backgroundImage = img;
        if (options && ('backgroundImageOpacity' in options)) {
            this.backgroundImageOpacity = options.backgroundImageOpacity;
        }
        if (options && ('backgroundImageStretch' in options)) {
            this.backgroundImageStretch = options.backgroundImageStretch;
        }
        callback && callback();
      }, this);
    }
function (url, callback, options) {
      return fabric.util.loadImage(url, function(img) {
        this.backgroundImage = img;
        if (options && ('backgroundImageOpacity' in options)) {
            this.backgroundImageOpacity = options.backgroundImageOpacity;
        }
        if (options && ('backgroundImageStretch' in options)) {
            this.backgroundImageStretch = options.backgroundImageStretch;
        }
        callback && callback();
      }, this);
    }
function ( url , callback , options ) { return fabric . util . loadImage ( url , function ( img ) { this . backgroundImage = img ; if ( options && ( 'backgroundImageOpacity' in options ) ) { this . backgroundImageOpacity = options . backgroundImageOpacity ; } if ( options && ( 'backgroundImageStretch' in options ) ) { this . backgroundImageStretch = options . backgroundImageStretch ; } callback && callback ( ) ; } , this ) ; }
Sets background image for this canvas
@method setBackgroundImage
@param {String} url url of an image to set background to
@param {Function} callback callback to invoke when image is loaded and set as background
@param {Object} options optional options to set for the background image
@return {fabric.Canvas} thisArg
@chainable
Sets background image for this canvas