Payload Adsign Plugin

OpenGraph Image Hook

Set meta.image from an image field

Usage

collections/Articles/index.ts
import { openGraphImageHook } from '@adsign/payload-adsign-plugin';

export const Articles: CollectionConfig = {
  fields: [
    {
      name: 'featuredImage',
      type: 'upload',
      relationTo: 'media',
    },
  ],
  hooks: {
    afterRead: [
      openGraphImageHook({
        imageField: 'featuredImage',
      }),
    ],
  },
};

How It Works

If meta.image is not set, the hook copies the value from the specified imageField to meta.image.

Options

OptionTypeDescription
imageFieldstringField containing the image to use

On this page