Closed (fixed)
Project:
Metatag
Version:
8.x-1.x-dev
Component:
Other tags
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
9 Oct 2017 at 19:48 UTC
Updated:
14 Feb 2022 at 10:10 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
ytsurkWhatch out - this will break W3C markup validation .. https://realfavicongenerator.net/faq
Comment #3
damienmckenna8-O
Oh my.
So right now the meta tag is completely pointless as it doesn't support the "color" attribute, but adding it will break HTML validation. Fun times.
Comment #4
gngn commentedJust in case somebody (like my customer) wants to have an "apple conform Mask icon" with the color attribute (you have to accept a HTML validation warning).
Setting to needs-review - even if it probably should not hardwire the color and offer some way to edit the color via UI!
Comment #5
gngn commentedSorry, wrong paths in the patch file.
Comment #6
damienmckennaThere needs to be an option in the form for this.
Comment #7
gngn commented@DamienMcKenna
I agree - but I do not know how to do this.
Overriding the function form() (in this case in metatag_favicons/src/Plugin/metatag/Tag/MaskIcon.php) just seems to change the element type form default 'textfield' to 'checkbox' or 'textarea'.
But how do I add an additional option?
I looked at https://www.drupal.org/docs/8/modules/metatag but did not find anything usefull.
Can you (or anybody else) point me in the right direction?
Comment #8
damienmckennaThat form() method just returns a regular Form API structure, so just add another item in the array with the key "color"; there are a few other tags in the codebase that extend that function, check with them for some examples.
Comment #9
gngn commentedThank you.
I still think that
function form(array $element = [])just returns one form element - at least in all the classes I looked at:All of these override
form(array $element = [])- but they just change the '#type' (e.g. 'select').I did manage to show an input for color, but I cannot save the color value (or get it into the config).
I tried something like this (also see comments):
I think I need to extend the schema metatag_favicons.metatag_tag.schema.yml ...
Btw: is there a reason the key is metatag.metatag_tag.mask_ico in metatag_favicons.metatag_tag.schema.yml when the id in the plugin is
id = "mask-icon"?The other ids seem to the same as the according schema keys (e.g. "apple_touch_icon_72x72").
The exported config has the key "mask-icon" (like the plugin).
Thanx for any feedback.
Comment #10
damienmckennaSo this took a bit more work than I expected due to some limitations in the internal APIs, sorry about that.
Please give this a try. It should be backwards compatible with the existing values.
Still to do: update the tests.
Comment #12
damienmckennaForgot to remove a dpm() line I'd added during local testing.
Let's try this again.
Comment #13
damienmckennaNeeds tests, especially for backwards compatibility.
Comment #14
gngn commented#12 worked for me, thanx.
Patch only applies to current dev, not to current stable 8.x-1.11, but hey.
Comment #15
jeroentCreated a reroll.
Comment #16
jeroentPatch attached fixes the failing tests, because of a missing config schema, and adds an upgrade path for old values.
This issue still needs tests but currently MetatagTagsTestBase only supports meta tags with only 1 value. So we should edit MetatagTagsTestBase so it's possible to support multiple values or add a separate test for the mask-icon metatag.
Comment #17
jeroentCS fixes.
Comment #18
damienmckennaGreat work, everyone!
I think this is almost perfect, it just needs test coverage.
Comment #19
damienmckennaComment #20
damienmckennaI think this also needs an update script to fix existing field data.
Comment #21
jeroent@DamienMcKenna,
An update script is already included in #17:
Comment #22
damienmckennaThat updates the default configurations, but not fields on entities.
Comment #23
jeroentPatch attached adds test coverage for the mask_icon.
Comment #25
jeroentAnd an upgrade path for entities. I based this one on one of the update hooks that was removed since the Drupal 9 compatibility changes.
Comment #26
jeroentComment #27
jeroentUpdated IS, Test coverage and update script to fix existing field data is provided.
Comment #28
jeroentI removed the maxlength from the color element, since that prevents the usage of tokens.
Comment #30
jeroentComment #31
jeroentPatch no longer applied, so I created a reroll.
Comment #33
jeroentComment #34
damienmckennaRerolled.
Comment #36
damienmckennaCommitted. Thank you all.
Comment #38
gngn commentedJust cause I am still using core 8.8 (yeah, I know...): here is a version of #34 which applies to 8.x-1.16
Only difference is in metatag_favicons/config/schema/metatag_favicons.metatag_tag.schema.yml:
182c182
< -metatag.metatag_tag.mask-icon:
---
> -metatag.metatag_tag.mask_ico: