We have an image that looks like the following via file_load():
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:
When those are combined it results in a file object like this:
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..
Comment | File | Size | Author |
---|
Comments
Comment #2
DamienMcKennaComment #3
DamienMcKennaComment #4
joseph.olstadWhich 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
Comment #5
DamienMcKennaI'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.
Comment #6
joseph.olstadJust to clarify: what are we expecting to have in the metadata?
I'm not sure yet what needs to be done.
Comment #7
DamienMcKennaThe 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.
Comment #8
joseph.olstadok, so if one of the fields is empty or zero length then the format should not be added to the metadata?
Comment #9
joseph.olstadThere's a patch here:
might help?
#2825484: Undefined index error when using media browser in custom field
Comment #10
DamienMcKennaThat 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.
Comment #11
LittleRedHen CreditAttribution: LittleRedHen commented@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... :-/
Comment #12
joseph.olstadComment #13
DamienMcKennaYes, the patch does resolve the problem, thanks for letting me know!
Comment #14
joseph.olstadwe 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
Comment #15
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedRecent 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