用户头像

User profile picture

我正在启动一个使用 apostrophe-cms 作为 CMS 的项目。 我需要的一件事是能够添加用户个人资料图片。 我看到他们提供的demo是可行的 here.

我已经搜索了如何执行此操作的文档,但没有看到直接提示。 有人能给我指出正确的方向吗?

亲切的问候

您想将 apostrophe-images 小部件添加到负责管理用户配置文件的部分的架构中,在本例中为 apostrophe-users

在你的lib/modules/apostrophe-users/index.js

module.exports = {
  addFields: [
    {
      name: 'thumbnail',
      type: 'singleton',
      widgetType: 'apostrophe-images',
      label: 'Profile Picture',
      options: {
        limit: 1,
        aspectRatio: [100, 100]
      }
    }
  ]
};

您可以更改 limitaspectRatio 以满足您的需要或完全忽略它们。

您可以通过查看代码来查看演示如何执行操作的代码

https://github.com/apostrophecms/apostrophe-sandbox/blob/master/lib/modules/apostrophe-users/index.js

https://github.com/apostrophecms/apostrophe-sandbox/