prismicio / prismic-next

Helpers to integrate Prismic into Next.js apps
https://prismic.io/docs/technologies/nextjs
Apache License 2.0
57 stars 7 forks source link

fix(PrismicNextImage): log error if no alternative text is available (only in non-production environments) #68

Closed angeloashmore closed 1 year ago

angeloashmore commented 1 year ago

Types of changes

Description

This PR adds a non-production error when <PrismicNextImage> does not have an available alt value.

<PrismicNextImage> uses the following priority to determine its alt value:

  1. Its alt prop ("" is the only valid value)
  2. The image field's alt property (set in Prismic)
  3. Its fallbackAlt prop ("" is the only valid value)

The error recommends setting Alternative Text in Prismic along with instructions on marking the image as decorative, if desired.

[PrismicNextImage] The following image is missing an "alt" property. Please add Alternative Text to the image in Prismic. To mark the image as decorative instead, add one of \`alt=""\` or \`fallbackAlt=""\`.

This error message is displayed just before next/image's built-in error which is logged in the same case as the above message. There is no way to disable the next/image error without providing an alt value, so this PR lets both errors log.

Checklist:

🐺