When using a a remote image for open graph image (og:image), metatag is output 3 times, twice incorrectly if using query string

e.g. add this to open graph image tag

https://i0.wp.com/www.brixtonbuzz.com/wp-content/uploads/2024/05/streath...

and compare to

https://i0.wp.com/www.brixtonbuzz.com/wp-content/uploads/2024/05/streath...

Comments

2dareis2do created an issue. See original summary.

mrcdrx’s picture

I can confirm this issue.

2dareis2do’s picture

Not sure if I have found a new bug or if this is related to this one but I also discovered that the use of delimiters in alt tags breaks the meta tag output for images.

In MetaManager->processTagValue() we have the following

 // Create options for handling token replacements, setting the current
    // language and a custom delimiter for multiple value fields in tokens.
    $options = [
      'langcode' => $langcode,
      'join' => ',',
    ];

This looks like it is using a comma for a delimiter.

In my meta image I had alt tag defined. I had used 2 commas!

e.g.

Serving the Community, Streatham Life, since 2006

Removing the use of commas in the alt tag field seems to resolve the issue with og:image being added multiple times. So with an image the site url is also appended. This appears to be repeated depending on how many delimiters you have.

Interestingly the first part of the alt text seems to be ignored but the following delimited strings are prepended.

So to summarise, strings with delimiters appear to be break the token replacement and the number of items returned.

This seems like a potential bug as commas appear to be allowed when entering a string in Drupal?

One solution might be too disable the use of certain delimiters when entering a string in Drupal.

Not sure what the query string issue is exactly but perhaps there is some other character being used as a delimiter when processing tag values?

Might be good to add a test for this scenario.

2dareis2do’s picture

damienmckenna’s picture

Issue tags: +Needs tests

Let's add some test coverage.

justinchev’s picture

This token seemed to work for me in order to only render the image url without the alt text and the problem commas.
[node:field_image:entity:url]