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.
When creating a node, under the Thumbnail Image section there are two radio buttons.
( ) No image (Facebook will choose one automatically).
( ) Provide a URL to a custom preview image.
Per default, No image should be selected because if I do nothing I get an error when trying to submit/save the node
"An illegal choice has been detected. Please contact the site administrator."
Comment | File | Size | Author |
---|---|---|---|
#6 | opengraph_meta-default_value_fix-6.patch | 1.68 KB | geoffreyr |
#5 | default-value-fix.patch | 1.84 KB | lehnle |
Comments
Comment #2
rajeev_drupal CreditAttribution: rajeev_drupal at TATA Consultancy Services for Pfizer, Inc. commentedI am also facing the same issue, while editing the node.Ideally it should work without selection of image as well.
Comment #3
jamesrice CreditAttribution: jamesrice commentedI have this issue as well, and it seems to potentially be further complicated when I try to setup a default value of the OG Image as well.
Comment #4
lehnle CreditAttribution: lehnle commentedIt seems to me that setting a default value for og:image causes the problem.
Leaving it blank uses the "no image" option as default.
Details:
in opengraph_meta.module the thumbnail image options include a blank
'' => t('No image (Facebook will choose one automatically).')
the other options are "harvested" from the node. The selected default value is then set by
So if og:image is set but does not correspond to a node image, the select will be broken.
Additionally even if the default value is a node token, e.g. [field_image], during the select widget creation this value does not seem to be resolved to the corresponding url. So the select field will not have the correct option pre-selected.
Comment #5
lehnle CreditAttribution: lehnle commentedAs suspected the token is not replaced during the select widget creation. So to pass the default select field validation the token has to be added to the '#options' array.
I created a patch that does this, while not actually rendering the option as a selectable choice.
If you do not want to patch the module, you could probably use hook_form_alter to do the same.
Untested, but something similar to this should work.
Comment #6
geoffreyr CreditAttribution: geoffreyr commentedThis is the same as #5 but with the paths tidied up so we can apply it against the module directly.
Comment #7
rajeev_drupal CreditAttribution: rajeev_drupal at TATA Consultancy Services for Pfizer, Inc. commentedComment #8
rajeev_drupal CreditAttribution: rajeev_drupal at TATA Consultancy Services for Pfizer, Inc. commented# 5 and and #6 both working for me. Thanks for patch.
Comment #9
rajeev_drupal CreditAttribution: rajeev_drupal at TATA Consultancy Services for Pfizer, Inc. commented