$class = isset($items[0]['override']['class']) ? $items[0]['override']['class'] : NULL;
$style = isset($items[0]['override']['style']) ? $items[0]['override']['style'] : NULL;
should be
$class = isset($items[0]['override']['attributes']['class']) ? $items[0]['override']['attributes']['class'] : NULL;
$style = isset($items[0]['override']['attributes']['style']) ? $items[0]['override']['attributes']['style'] : NULL;
I found that while trying to figure out while the alignment and styles were not being saved when adding a media colorbox formatted image through the Wysiwyg.
That was part of the problem not all of it. After fixing that, the style gets saved, but you lose it again on re-edit. The alignment value never gets saved at all. I wound up doing this:
$class = isset($items[0]['override']['attributes']['class']) ? $items[0]['override']['attributes']['class'] : NULL;
$style = isset($items[0]['override']['attributes']['style']) ? $items[0]['override']['attributes']['style'] : NULL;
$align = isset($items[0]['override']['attributes']['align']) ? $items[0]['override']['attributes']['align'] : NULL;
if($align) {
$style = isset($style) ? $style . 'float:' . $align : 'float:' . $align;
}
Bit that was only a quick fix. All these values get lost again on re-editing the node. If you make function media_colorbox_field_formatter_view return nothing at all while on an edit page, then you get a placeholder image, but the styles and alignment are correct.
Using Media 7.x-2.x-dev.
Comments
Comment #1
kjl commentedComment #2
leanne9 commentedI am sorry I am no help... but maybe you can help me-- how are you getting Media Colorbox to work in a WYSIWYG at all? With the "add media" button I can insert an image if I select "Current format is: Large" which goes in as
and it renders the photo correctly ... But if I select the "Colorbox" format it gives
[[{"type":"media","view_mode":"colorbox","fid":"875","attributes":{"alt":"","class":"media-image","typeof":"foaf:Image"}}]]which renders as "image-x-generic.png" (grey icon image).
I am using the TinyMCE editor.
Comment #3
makli commentedI've the same problem as kjl. If re-editing the node in the wysiwyg-editor the previously adjusted float-settings get lost.
Comment #4
jurgenhaasSame problem here. Also, $class and $style will be arrays and should be imploded before used as #item_class and #item_style in the themeing variable array.
Comment #5
David_Rothstein commentedPossible duplicate of #1431714: Colorbox image lost the float formatting?