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 selecting an image from the library tab and submitting I get the following error (on the screen where you can select the options 'display as', 'alt text' and 'title text':
Warning: Invalid argument supplied for foreach() in media_filter_field_parser() (line 417 of sites/all/modules/contrib/media/includes/media.filter.inc).
When I debug the $tag_info['fields']:
array (
[fields] => undefined
)
The only fix I found was to change this piece of code (on line 417):
if (isset($tag_info['fields']))
into:
if (isset($tag_info['fields']) && $tag_info['fields'] != 'undefined')
Anyone has the same issue/has a better solution to solve this issue?
Thanks in advance!
Comments
Comment #1
valgibson CreditAttribution: valgibson commentedYes, I have the same issue, but only on test-environment, not local. Haven't solved it yet.
Comment #2
f0ns CreditAttribution: f0ns commentedOke, let me know if you may find a solution or the cause of this issue
Comment #3
bneil CreditAttribution: bneil commentedIs this happening only when you try to embed a file in the WYSIWYG?
Do you have any custom fields on the file type?
If so, when you edit any of those fields on the file type, is "Override in WYSIWYG" checked? If so, uncheck it and try again. Taxonomy isn't supported as a field that's "overridable" in the WYSIWYG and there are other types that aren't either. See: #2062365: Several types of fields are not being handled correctly when file is embedded in the WYSIWYG and #2062721: Add a white list of file fields that can be overwritten when the file is added in the wysiwyg
Working on #2062721: Add a white list of file fields that can be overwritten when the file is added in the wysiwyg would help make it so some of the known fields don't have the override checked.
Comment #3.0
bneil CreditAttribution: bneil commentedfixed typo
Comment #4
f0ns CreditAttribution: f0ns commented@Valgibson Maybe this is related to PHP versions? What versions are you using local/test environment?
update: Tried with latest dev version, still have this problem on servers (not on local environment). The only change is the file now is media_wysiwyg.filter.inc (/media/modules/media_wysiwyg/includes/) and that the line to 223 should be:
if (isset($tag_info['fields']) && $tag_info['fields'] != 'undefined') {
instead of
if (isset($tag_info['fields']) {
To resolve this issue
Comment #5
valgibson CreditAttribution: valgibson commentedYes in my case this was indeed related to PHP versions. It was fixed by checking using !empty() but after all it didn't seem to be relevant anymore, while we had to use another method for attaching images, due to jquery version issues and related problems. Thanks anyway for the effort.
Comment #6
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedClosing this issue as outdated. However, if you think this issue is still important, please let us know and we will gladly re-open it for review.
sincerely,
- the Drupal Media Team