Closed (fixed)
Project:
Metatag
Version:
8.x-1.x-dev
Component:
Open Graph
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
7 Jul 2016 at 04:31 UTC
Updated:
30 Jan 2026 at 16:10 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
lukasss commentedI also had that problem!
I tested and concluded that the metatag is not being!
This is 99%
I'm getting this error with the module https://www.drupal.org/project/field_tokens
I am preparing a patch to fix it!
Comment #3
lukasss commentedComment #4
seancasey commented@lukasss, why did this issue get closed and marked as "works as designed"?
Comment #5
lukasss commentedI'm sorry. Dear @seancasey, change the issue as you see fit
Comment #6
damienmckennaI'm reopening this to fix image handling so it only looks at the SRC attribute of the IMG tag.
Comment #7
seancasey commentedThanks, @DamienMcKenna.
Rather than just modifying the current og:image (and og:image_url) parsing code in the submodule, I would suggest just borrowing the way the image field gets parsed from the image_src tag in the metatag module. I believe that tag works fine, and it would be good for internal consistency to have the submodules parse the url from the image field in the same manner.
Comment #8
damienmckennaComment #9
damienmckennaWorking on porting D7's image tests to D8. This is a copy/paste/rename-some-things first step, more to come.
Comment #10
luksakJust faced this issue as well. Weird enough that the image_src metatag doesn't have this issue with the exact same tokens. Is this because og:image is set to be multi value?
Comment #11
damienmckennaLets do the tests in #2628472: Write tests for image handling first and then work on fixing this.
Comment #12
lmeurs commented@Lukas von Blarer: It indeed only happens to image metatags which may contain multiple values.
MetaNameBase::parseImageURL()explodes$valueby commas which may occur between tags as separator, but may also occur inside attributes or even outside image tags depending on whatever the field formatter returns.I attached a patch which explodes by commas of they are actually between tags, but also I added a URL validator just to be sure. I guess there still are situations that are uncovered since the implementation heavily leans on comma separated tags which totally depends on the result of field formatters, but I hope the patch is a small improvement.
Comment #13
damienmckenna8.x-1.0 is out, so this is fair game again.
Comment #16
damienmckennaNeed to finish #2628472: Write tests for image handling first.
Comment #17
nkrafthi! I'm experiencing the same issue -- any alt tag with a comma in it is causing the [node:field_image] token to not render the og:image tag correctly -- instead it outputs mangled html, like so:
I'm not experienced at testing/fixing modules. We have a site about to go into Production, and this is proving to be a major issue for is. Any ideas on how i could remedy this (removing alt tags is not an option, and deleting all commas in thousands of alt tags also not an option.)
Thanks for any help you can provide.
Comment #18
idiaz.ronceroHello;
I can report the same problem and field_tokens is not the issue because i'm not using it.
I'm using metatag 8.x-dev.
Comment #19
roshkovanv commented@lmeurs, this will not work correctly if you have something like this:
"[node:field_image],http://my_site.example/themes/custom/my_theme/fallback_image.png" <- the path to a fallback image...
Comment #20
roshkovanv commentedComment #21
roshkovanv commentedComment #22
damienmckenna@roshkovanv: Thanks for your work on this. As soon as #2628472: Write tests for image handling is finished I'll be able to review the implications of this, and improve the tests.
Comment #23
bkosborneFYI, For those looking for a quick fix, you can avoid this issue entirely since #2611866: Add image style tokens for image fields was committed to the Token module. You can get the raw URL for an image style via tokens, instead of just getting the HTML markup of the image. In fact, maybe Meta Tag should indicate that in the description for such image fields, because it's not obvious you can use tokens like this (they don't appear in the token browser).
See the patch in the reference issue for the format for the token. This allows you to control the image style as well :)
Comment #24
boobaaRerolled the patch from #21 (#2911435: Streamline the HTML output logic made it inapplicable). Now my
og:imagetag renders properly even if I use the original image from an image field which has analtattribute containing comma(s) and I don't override anything in thetokendisplay mode.Comment #25
_san_ commentedAny plans to release the fix for this? If more development is needed, I'm willing to help.
Comment #26
damienmckennaComment #28
ZapevalovAnton commentedPatch #24 not work for me.
Comment #29
andrewsuth commentedRerolled patch #24 for the latest metatag release (8-x-1.4).
Comment #30
damienmckennaLet's see what the testbot says.
Comment #32
andrewsuth commentedahh OK rerolled for 8.x-1.x-dev branch ..
Comment #33
andrewsuth commentedComment #35
greenskin commentedRerolled patch from #32 for 8.x-1.16.
Comment #36
greenskin commentedMissed the
usestatement for UrlHelper. Updated patch.Comment #37
damienmckennaLet's run that one by the testbot.
Comment #40
plachI had created a patch for this bug before finding the issue, I'm posting it anyway, just in case it is deemed useful. Not to say this should be the new "official" patch to review now, just curious to see if the testbot likes it.
Comment #42
plachThis should work better.
Comment #44
damienmckennaI committed #42. Thank you.
Comment #46
vikicica22 commentedThis error has occurred again. Please investigate.
Drupal Version: 9.5.2
Metatag: 8.x-1.x-dev
Comment #47
damienmckennaPlease open a new issue and provide details of the errors that show on your site, your site's logs, etc that might help track down the problem.
Comment #48
2dareis2do commentedI am also experiencing similar issue with Drupal 10.x with Metatag 2.1.0..
https://www.drupal.org/project/metatag/issues/3449691#comment-16299868
Comment #49
justinchev commentedNot a fix for the underlying problem, but this token seems 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]