我是keystone的新手。我想在管理员界面中调整图像大小。我正在使用CloudinaryImage。这是我的代码
keystone.js
require('dotenv').load();
var utils = require('keystone-utils');
// Require keystone
var keystone = require('keystone'),
handlebars = require('express-handlebars');
utils = keystone.utils;
var cloudinary = require('cloudinary')
, fs = require('fs');
var config = require ('./config');
keystone.init({
'name': 'WISTLA',
'brand': 'WISTLA',
// 'sass': 'sass', // previously 'public'
'static': 'public',
'favicon': 'public/favicon.ico',
'views': 'templates/views',
'view engine': 'hbs',
'custom engine': handlebars.create({
layoutsDir: 'templates/views/layouts',
partialsDir: 'templates/views/partials',
defaultLayout: 'default',
helpers: new require('./templates/views/helpers')(),
extname: '.hbs'
}).engine,
'auto update': true,
'session': true,
'auth': true,
'user model': 'CrmUser',
'cookie secret': '2Vwn2mpd@-^ZRA7a}pQd(^y|u9%RC_c|:49D^zyGF_@?x1NmEoX75o7mlin9;IRt',
//'mongo': config.dbUrl
'mongo': 'mongodb://localhost/wistla-web'
});
keystone.import('models');
keystone.set('cloudinary config', {
cloud_name: 'my-cloud-name',
api_key: 'my-api-key',
api_secret: 'my-api-secret-key'
});
keystone.set('locals', {
_: require('underscore'),
env: keystone.get('env'),
utils: keystone.utils,
editable: keystone.content.editable
});
keystone.set('routes', require('./routes'));
keystone.set('nav', {
'crm-users': 'crm-users',
'Mosaic':'Gallery',
'Cities':'Cities',
'Tiles text':'Tiles',
'LogoLinks':'LogoLinks',
'Team':'TeamAdvisory',
'Press':'Press',
'Jobs':'Job',
'Terms':'Terms',
'Privacy':'Privacy'
});
keystone.start();
模型
var keystone = require('keystone'),
Types = keystone.Field.Types;
/**
* TeamAdvisory Model
* ==========
*/
var TeamAdvisory = new keystone.List('TeamAdvisory', {
map: { name: 'name' },
autokey: { path: 'slug', from: 'name', unique: true },
sortable: true
});
TeamAdvisory.add({
name: { type: String, required: true },
title: { type: String},
content: {
bio: { type: Types.Html, wysiwyg: true, height: 150 }
},
image: { type: Types.CloudinaryImage, publicID: 'slug', folder: 'public/cms-images/team/'},
flag: { type: Types.Select, options: 'Team, Advisory', default: 'Team', index: true }
});
TeamAdvisory.schema.virtual('content.full').get(function() {
return this.content.bio;
});
TeamAdvisory.defaultColumns = 'name, title|20%, content.bio|20% ,flag|20%';
TeamAdvisory.register();
之后我重新启动服务器。我收到了这个错误。
Error: Invalid Configuration
CloudinaryImage fields (TeamAdvisory.image) require the "cloudinary config" option to be set.
See http://keystonejs.com/docs/configuration/#services-cloudinary for more information.
at new cloudinaryimage (/home/rohit/wistla-web/node_modules/keystone/fields/types/cloudinaryimage/CloudinaryImageType.js:39:9)
有没有办法调整图像大小。
答案 0 :(得分:1)
在keystone.js
.set('cloudinary config', ...)
.import('models')
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: EXC_I386_GPFLT
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_c.dylib 0x00007fff92d6b859 strtol_l + 77
1 controller_2 0x0000000100006b57 main + 4839
2 controller_2 0x00000001000010b4 start + 52
之前+4839
。