Incorrect Meta Tag Output for Media Fields with Commas in Alt Text on Drupal 10.2.4 with Metatag 2.0.0

Created on 14 March 2024, 4 months ago

Problem/Motivation

Similar to the issue previously reported in #2761909 πŸ› og:image does not parse url from image field properly when there is a comma in the alt field Fixed , particularly noted in comment #46, we are experiencing a reoccurrence of an error with the Metatag module when using media fields in place of image fields. This issue is being reported as advised in comment #47 of the aforementioned issue thread. Our environment uses Drupal version 10.2.4 with the Metatag module version 2.0.0. The problem manifests when the default image field in the Article content type is replaced with a media field that references the Image media type, and tokens like [node:field_media:entity:thumbnail] or [node:field_media:entity:field_image] are used. The issue leads to incorrect meta tag outputs when the alt text contains commas, further complicated by the inability to modify alt text on already uploaded media due to issue #3232414 πŸ› Image Media thumbnail alt text cannot be changed without reuploading the image Needs work .

Steps to reproduce

  1. Remove the default image field from the Article content type.
  2. Add a media field that references the Image media type to the Article content type.
  3. Go to Configuration > Metatags, add default metatags, then select 'Article'.
  4. Edit the 'Article' metatag settings, adding the [node:field_media:entity:thumbnail] token to the image field.
  5. Create a media item of type Image with alt text containing commas.
  6. Create content of type Article, add the media with comma-inclusive alt tags, and save.
  7. View the page source of the saved node and observe the malformed meta tag output.

Example of incorrect meta tag output:

<meta property="og:image" content="https://www.mydomain.com/sites/default/files/2024-03/compass.png" />
<meta property="og:image" content="https://www.mydomain.comsymbolizing clarity and direction in a journey through uncertainty" />
<meta property="og:image" content="https://www.mydomain.comhighlighted by vibrant contrasting colors" class="image-field" />

Proposed resolution

Further investigation is needed to pinpoint the exact cause and find a solution. This issue has been opened for record-keeping and to facilitate collaboration among users who might be experiencing similar problems. Preliminary steps will include confirming whether this issue also affects standard image fields and testing against the 2.0.x-dev version of the Metatag module.

Remaining tasks

Confirm the issue's occurrence with standard image fields and with the 2.0.x-dev version of the Metatag module. Further investigation is required to understand the scope and potential fixes.

User interface changes

No UI changes are anticipated as a result of addressing this issue.

API changes

No API changes are anticipated.

Data model changes

No data model changes are anticipated.

πŸ’¬ Support request
Status

Active

Version

2.0

Component

User interface

Created by

πŸ‡¦πŸ‡ΊAustralia thursday_bw

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024