0.4.1-rc2 • Published 8 years ago

bookshelf-imageclip v0.4.1-rc2

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

bookshelf-imageclip

THIS PACKAGE DOES NOT HAVE A STABLE RELEASE JUST YET. USAGE MAY CHANGE. SEE MILESTONES.

Installation

npm install bookshelf-imageclip

Usage

Best to look at the tests.

Your schema must include <field>_file_name.

bookshelf.Model.extend({
  tableName: 'users',
  imageClip: {
    <field_name>: {
      <style_name>: {
        process: function( gm, model ) {
          return gm.resize( "500x500" ); //See node-gm documentation
        }
      }
    }
  }

Examples

    var bookshelf = require('bookshelf')(knex);
    bookshelf.plugin(require('bookshelf-imageclip'), {useImageMagick: true});
    
    User = bookshelf.Model.extend({
      tableName: 'users',
      imageClip: {
        avatar: {
          original: {
            process: function( gm, model ) {
              return gm;
            }
          },
          medium: {
            process: function( gm, model ) {
              return gm.resize( "500x500" ) ;
            }
          },
          thumb: {
            process: function( gm, model ) {
              return gm.resize( "100x100" ) ;
            }
          }
        }
      }
    });
    
    User.forge( )
        .save( { avatar: "http://hamburgerhelper.com/pigeon.jpg" } )
        .then( function( user ) {
          console.info( user.get( "avatar" ).medium ) // outputs: images/244/8ea/avatar/medium/pigeon.jpg
        } );

Roadmap

See issues for milestones and changes for first stable release.

Contributing

I'd be happy to pull in any requests as long as you add tests.

0.4.1-rc2

8 years ago

0.4.1-rc1

8 years ago

0.3.3

10 years ago

0.3.2

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago