问题
I'd like to know if it's possible, and how much of an effort it would be to use S3File as an image field in KeystoneJS. My testing indicates that while you can indeed upload an image to an S3File, the admin interface treats it as an arbitrary file. The thing I'm missing the most is a preview function like Types.CloudinaryImage provides.
Is the autogenerated admin interface easily extensible without it being ugly hacks? Or is it meant to be left untouched because of the simple fact that it already does so much for you?
回答1:
Looks like they intend to improve this.
https://gist.github.com/JedWatson/8519769
https://github.com/JedWatson/keystone/issues/165
My hack solution is to directly edit the keystone template file in node_modules - until these issues are resolved. Edit node_modules/keystone/templates/fields/s3file/form.jade
and add wherever you want:
img(src=item.get(field.paths.url))
Then remember to revert this hack after it's officially supported (as updates will blow away the hack).
来源:https://stackoverflow.com/questions/22345191/using-s3file-for-images-in-keystonejs