Consider the following code created by the WYSIWYG plugin:
[[{"type":"media","view_mode":"media_large","fid":"875","attributes":{"alt":"","class":"media-image image-style-large","height":"306","typeof":"foaf:Image","width":"408"}}]]

In media_token_to_markup() this will be decoded to a PHP array with the function drupal_json_decode(). You will end up with an array where $tag_info['attributes']['class'] is a string. This one is later used as the class attribute for a render array, but there the the type must be an array, not a string. This has been causing major issues in #1711746: Fatal error after updating from 3.x to 3.0.
I'm attaching a patch that will make the class attribute an array instead of a string.

CommentFileSizeAuthor
media-7.x-2.x-fix-class-array.patch691 bytesJimmyAx
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

marcoka’s picture

i can confirm this.
this happens with 1.2 too, hello WSOD.

used the patch, fixes it. its a fix of data that is just beeing provided the wrong way. maybe this should be fixed at the "root" of the problem.

JimmyAx’s picture

Fixing it at the "root" of the problem would in this case probably mean to make the class attribute a json array. This would require you to modfy any existing database entries too. That might not be really feasible so this patch is probably easiest way to fix the bug.

marcoka’s picture

agree. just to note that i meant. its an effective fix that is pretty understandable. i always comment my code with //@todo ... thats what i meant

Jeff Burnz’s picture

Priority: Major » Critical

This should be critical, it causes a fatal error when other themes or modules correctly add a class to what should be an array.

Jeff Burnz’s picture

Similar issue opened for User Badges module, just linking to for reference so others can find workarounds etc, this is looking like a more widespread issue and needs to be highlighted for module developers: #1748394: Class attributes should be an array, not a string

Dave Reid’s picture

Issue tags: +sprint, +Media Initiative
Dave Reid’s picture

Status: Needs review » Fixed

Automatically closed -- issue fixed for 2 weeks with no activity.