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

valgibson’s picture

Yes, I have the same issue, but only on test-environment, not local. Haven't solved it yet.

f0ns’s picture

Oke, let me know if you may find a solution or the cause of this issue

bneil’s picture

Is 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.

bneil’s picture

Issue summary: View changes

fixed typo

f0ns’s picture

@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

valgibson’s picture

Issue summary: View changes

Yes 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.

Chris Matthews’s picture

Version: 7.x-2.0-alpha2 » 7.x-2.x-dev
Status: Active » Closed (outdated)

Closing 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