Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Using Yoast SEO and Metatags, our description field gets filled with a WYSIWYG field value. This value is appearing with HTML, which is unwanted. And although the Metatags module filters that out on rendering the metatags, even showing this HTML in the node edit form is unwanted (in the Metatag field).
I will attach a patch that uses the Metatags built-in code to retrieve a metatag value, which accounts for the 'metatag_token_sanitize' setting.
Comment | File | Size | Author |
---|---|---|---|
#6 | strip_tags_description_field-2876004-6.patch | 793 bytes | marco-s |
#4 | yoast_seo-2876004-sanitize_metatag_tokens-3.patch | 1.05 KB | Koen.Pasman |
Comments
Comment #2
Koen.Pasman CreditAttribution: Koen.Pasman at Aubergine IT commentedPatch attached.
Comment #3
Koen.Pasman CreditAttribution: Koen.Pasman at Aubergine IT commentedComment #4
Koen.Pasman CreditAttribution: Koen.Pasman at Aubergine IT commentedMinor edit, replacing short array notation.
Comment #5
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedThis patch caused major errors.
Every module with a token gave a similar error
Notice: Trying to get property of non-object in token_tokens() (line 385 of modules/all/token/token.tokens.inc).
Notice: Trying to get property of non-object in token_tokens() (line 385 of modules/all/token/token.tokens.inc).
Comment #6
marco-sWhy don't you just use the PHP strip_tags function?
Comment #7
johnennew CreditAttribution: johnennew at Deeson commentedPatch in #6 fixed the issue for me. Thanks.
Comment #9
KingdutchCommitted! Thanks everyone for helping out! :)