On a site I maintain they have their Image file_entity bundle set up with a Link field. When an image with a filled-in Link field is added to a node's body field using the WYSIWYG module integration, the embedded file entity code ends up with invalid JSON, so media_wysiwyg_token_to_markup() is unable to extract the file information to display it.
The embedded media code looks like this:
[[{"fid":"123","view_mode":"default","fields":{"format":"default","field_file_image_alt_text[und][0][value]":"","field_file_image_title_text[und][0][value]":"","field_caption[und][0][value]":"","field_link[und][0][url]":"<a href="http://example.com/">http://example.com/</a>","field_iptc_object_name[und][0][tid]":"","field_iptc_object_name[und][0][value]":"","field_iptc_object_name[und][0][timezone]":"","field_iptc_object_name[und][0][value2]":"","field_exif_imagedescription[und][0][tid]":"","field_exif_imagedescription[und][0][value]":"","field_exif_imagedescription[und][0][timezone]":"","field_exif_imagedescription[und][0][value2]":"","field_iptc_keywords[und][0][tid]":"","field_iptc_keywords[und][0][value]":"","field_iptc_keywords[und][0][timezone]":"","field_iptc_keywords[und][0][value2]":"","field_iptc_keywords[und][0][_weight]":"0","field_gallery_id[und][0][value]":""},"type":"media","attributes":{"height":732,"width":500,"class":"media-element file-default"},"link_text":null}]]
Both the Default and WYSIWYG view modes for the Image file entity bundle have the "Link" field set to "Hidden".
Checking the database, the file_link_url value just contains "http://example.com/".
As you can see, the field_link's "url" value is converted to a link when it is added to the WYSIWYG. The value is first converted to a link and then the string is not encoded properly in the jSON, most likely the quotes around the URL in the link.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | media-n2762817-6.patch | 1.01 KB | damienmckenna |
Comments
Comment #2
damienmckennaComment #3
damienmckennaComment #4
damienmckennaDigging through it more, the value stored in the node's body field is actually the following:
This means that the value is being changed prior to getting to text_field_load().
Comment #5
damienmckennaOk, so the problem turned out to be that the "Convert URLs into links" filter was running before the Media filter and was breaking the JSON.
Comment #6
damienmckennaThis updates the help message on the Media filter recommending it be ran before the "Convert URLs" filter.
Comment #7
damienmckennaComment #8
nebel54That hint is a great idea (took me some time to find the problem today), patch still works for both (3.x and 2.x).
Comment #11
joseph.olstad