mazze's picture

Hi, a possible customer wants to upgrade its large D7 site. He made use of the Media CKEditor module in Drupal, which embeds images in WYSYWYG field with code like

<p>[[{"fid":"5916","view_mode":"default","fields":{"format":"default","alignment":"center","field_file_image_alt_text[und][0][value]":false,"field_file_image_title_text[und][0][value]":false},"type":"media","field_deltas":{"2":{"format":"default","alignment":"center","field_file_image_alt_text[und][0][value]":false,"field_file_image_title_text[und][0][value]":false}},"attributes":{"class":"media-element file-default media-wysiwyg-align-center","data-delta":"2"}}]]</p>

Is there any function in Backdrop CMS which converts this code into proper media asset code <img src="..."/>. Or is there any function in D7 to get rid of the module before upgrading?

Any comment is very welcome:-)


I don't know of any module that will do it, but I wonder if you could write a custom module that loads every node, runs text area fields through the filters and then resaves the nodes to write the filtered markup into the fields?

I've worked on a script that will convert custom blocks (and translations), blocks in layouts, and long text fields (text_long, text_with_summary) in entities. It will convert simple image file entities (with no custom fields) to the embedded image provided by Backdrop; and it converts video file entities (with no custom fields) to Video Filter tokens:

[video:/ width:900 align:left]

Let me know how that works for you and if you have any improvements you can share back.

For now this script does the trick for me but someone is free to adapt it for their own uses or turn it into a friendlier GUI or whatever.

mazze's picture

Wow Herb, this is great news. I am in some other projects with tight deadlines, but will have a look at this soon:-) Thank you for sharing!