Empty values not removed from multi-value meta tags

Created on 1 August 2023, over 1 year ago
Updated 28 April 2024, 8 months ago

Problem/Motivation

In our site improper empty og:image tags were generated. It was, because we used a definition for the og:image field where multiple values were allowed. If all of the fields have value, everything is ok. The MetatagManager.php replaces the given tokens and creates a proper temporary value which will be processed well. But if any of them is missing, the result will not be proper, the html source will also contain empty "og:image" meta tags.

Steps to reproduce

Set the following metatag to Open Graph, image:

[node:field_image:max_1300x1300], [node:field_images:max_1300x1300], [node:field_logo:max_1300x1300], [node:field_result_logo:max_1300x1300]

It will generate 3 og:image metas to the header of the content pages (unless you have such fields with content in them) with the base url of the site.

Proposed resolution

I have a kind of solution patching the MetatagManager.php where the empty values are removed. However some might create a more elaborate solution.

Related issues

This bug has been already reported by me here: https://www.drupal.org/project/metatag/issues/3182954 โ†’

The status of that ticket is "Closed (won't fix)" + I was requested to create a new issue if the modifications in #3067803 won't fix this one. So here it is, I think #3067803 did not addressed this bug or has not been included in the code for more than a year.

๐Ÿ› Bug report
Status

Needs work

Version

2.0

Component

Code

Created by

๐Ÿ‡ญ๐Ÿ‡บHungary zolt_toth

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024