Problem/Motivation
Similar to the issue previously reported in #2761909, 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.
Steps to reproduce
- Remove the default image field from the Article content type.
- Add a media field that references the Image media type to the Article content type.
- Go to Configuration > Metatags, add default metatags, then select 'Article'.
- Edit the 'Article' metatag settings, adding the
[node:field_media:entity:thumbnail]token to the image field. - Create a media item of type Image with alt text containing commas.
- Create content of type Article, add the media with comma-inclusive alt tags, and save.
- 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.
Comments
Comment #2
thursday_bw commentedComment #3
damienmckennaAn option was added in v2 on the settings page to change the separator from a comma to something else, e.g. a pipe symbol, that should solve your problem. Please give that a try and see if the problem still exists.