Using S3File for images in KeystoneJS

谁说胖子不能爱 提交于 2020-01-02 19:29:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!