christroutner

Image Upload - models/ImageUpload.js

Nov 24th, 2015
411
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var keystone = require('keystone');
  2. var Types = keystone.Field.Types;
  3.  
  4. /**
  5.  * Image Upload Model
  6.  * ===========
  7.  * A database model for uploading images to the local file system
  8.  */
  9.  
  10. var ImageUpload = new keystone.List('ImageUpload');
  11.  
  12. ImageUpload.add({
  13.         //name: { type: Types.Key, required: true, index: true }, //requiring name breaks image upload.
  14.         name: { type: Types.Key, index: true},
  15.         image: {
  16.                 type: Types.LocalFile,
  17.                 dest: 'public/uploads/images',
  18.                 label: 'Image',
  19.                 allowedTypes: [ 'image/jpeg', 'image/png', 'image/gif'],
  20.                 filename: function(item, file) {
  21.                         return item.id + '.' + file.extension;
  22.                 }
  23.         },
  24.         alt1: { type: String },
  25.         attributes1: { type: String },
  26.         category: { type: String },      //Used to categorize widgets.
  27.         priorityId: { type: String },    //Used to prioritize display order.
  28.  
  29. });
  30.  
  31.  
  32. ImageUpload.defaultColumns = 'name';
  33. ImageUpload.register();
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×