Images for collections?

default discord avatar
eypacha
2 weeks ago
1 1

Hi everyone!

Is there a simple way to add images to collections like you do with blocks? Or would you have to develop a plugin for that? I am not referring to the images field but to the imageURL option of the blocks.

Thanks

  • default discord avatar
    matthijs166
    2 weeks ago

    The way to go is to use the relationship field (Documentation)

    My recommendation is to look and try the public demo. There is an example there on how to reference the media collection:
    (https://github.com/payloadcms/public-demo/blob/master/src/blocks/Media.ts)

    2 replies
  • default discord avatar
    eypacha
    4 days ago

    I don't think I'm expressing myself correctly (I don't speak English natively)

    In the blocks there is a property called imageURL that allows you to choose an image to be displayed in the block list
    blocks

    However, I cannot do the same in the collections
    collections

    Is there a way to do that?

  • default discord avatar
    matthijs166
    3 days ago

    You could build your own dashboard components. There is at the moment no way to add icons in those dashboard tiles.

    Also, payload 2.0 coming soon (I'm very excited) Don't know what will happen to the dashboard then.

    This will maybe help you for building out your dashboard:
    https://www.youtube.com/watch?v=ZXoi9sYk96k&t
    https://www.youtube.com/watch?v=ZyfZ3HIwY94

    You can use the current dashboard as starting point, and customize it until you got it how you want:

    const Dashboard: React.FC<Props> = (props) => {

    Your config would like something like this:

    export default buildConfig({
      admin: {
        components: {
          views: {
            Dashboard: MyCustomDashboard,
          },
        },
      },
    });

    Also helpful:
    https://payloadcms.com/docs/admin/components

Open the post
Continue the discussion in GitHub
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.