We have an image that looks like the following via file_load():
The raw file_load() output.

When this file was embedded using Media WYSIWYG the string looks like the following:

e.g.: [[{"fid":"5336","view_mode":"media_original","fields":{"format":"media_original","field_file_image_alt_text[und][0][value]":"","field_file_image_title_text[und][0][value]":"","field_image_description[und][0][value]":"","field_media_tags[und][term_entry]":"","field_media_tags[und][terms]":""},"type":"media","link_text":null,"attributes":{"style":"width: 183px; height: 144px; float: left;","class":"media-element file-media-original"}}]]

Then, when media_wysiwyg_token_to_markup() processes the string it gets turned into this:
JSON
When those are combined it results in a file object like this:
The file object with the JSON loaded on top of it.
As you might guess, when this is passed through file_view_file() and the text fields are processed it results in the following error:

Notice: Undefined index: format in _text_sanitize() (line 349 of text.module).

What I haven't worked out yet is why the invalid data is being stored via Media WYSIWYG..

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DamienMcKenna created an issue. See original summary.

DamienMcKenna’s picture

DamienMcKenna’s picture

Issue summary: View changes
joseph.olstad’s picture

Which version of file_entity are you using?

I am using 7.x-2.0-beta3
with these two patches:

- projects[file_entity][patch][2000934] = https://www.drupal.org/files/issues/allow_selection_of-2000934-30.patch
- projects[file_entity][patch][2198973] = https://www.drupal.org/files/issues/file_entity_override_widgets-2198973-01.patch

DamienMcKenna’s picture

I'm using File Entity 7.x-2.0-beta3 and Media 7.x-2.0-beta5, both without any patches. I've just confirmed this happens with new content that is added, so it isn't a case of old data being misconfigured.

joseph.olstad’s picture

Just to clarify: what are we expecting to have in the metadata?

I'm not sure yet what needs to be done.

DamienMcKenna’s picture

The metadata should't have field_image_description[und][0][value]":"", if it's not going to also have field_image_description[und][0][format]":"", because that leads to the "undefined index: format" error when the content is viewed.

joseph.olstad’s picture

ok, so if one of the fields is empty or zero length then the format should not be added to the metadata?

joseph.olstad’s picture

DamienMcKenna’s picture

That patch didn't help.

I've ran out of time to continue working on this today, will try to pick it up again in a few days.

LittleRedHen’s picture

@DamienMcKenna, do you have the Better Formats module enabled on your site, by chance? I ran into this error when I had Better Formats configured to only permit HTML content, which meant better_formats removed the format field from the edit form.

If you do have that module set up, there's a patch at https://www.drupal.org/node/2832330 which might help: it ensures that the format field is always present by converting it to a hidden field instead of removing it.

If you don't have that module, then there must be multiple causes of this particular failure mode... :-/

joseph.olstad’s picture

Status: Active » Postponed (maintainer needs more info)
DamienMcKenna’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

Yes, the patch does resolve the problem, thanks for letting me know!

joseph.olstad’s picture

Category: Bug report » Support request
Status: Closed (duplicate) » Postponed

we should probably keep this open until the upstream patch for better formats is committed /released OR as a minimum until this gets added to the Readme.txt

Chris Matthews’s picture

Status: Postponed » Closed (outdated)

Recent versions of media have resolved most of peoples concerns and is compatible with entity translation, multilingual and various advanced configurations. Due to the high volume of inactive and most often irrelevant issues we are Closing this as (outdated). If for whatever reason this issue is important to you AND you still have issues after checking the media recipe documentation, then let us know and we will review your concerns.

Otherwise, see the recipe documentation for how to configure media and for troubleshooting tips OR refer to the media_dev distribution if you want to see a working media setup.

As mentioned, feel free to make some noise in this issue if you still feel it is important to you or someone else.

Thanks,

Media team