Has anyone successfully parsed the rich editor/trix field from the raw data in the database?

I have an application that has used the trix editor for a while. I need to migrate this data to a new application that also uses the trix editor for the same field but the difference in this new application is that it doesn't allow file uploads in the field like the old application did. Wondering what the best way would be to rip those files out of the body of that field and upload them properly for the record. Anyone have any experience here?
Solution:
trix is just json no? So write a migrator, parse the data get the files, download them to a folder structure, then migrate accordingly? Simple laravel console command/
Jump to solution
4 Replies
Solution
toeknee
toeknee4w ago
trix is just json no? So write a migrator, parse the data get the files, download them to a folder structure, then migrate accordingly? Simple laravel console command/
morty
mortyOP4w ago
No it looks like this:
<div>Head Bearing: NTN P310 (UC 310-115)<br><br>Drive belt: 2 x B55<br><br>Chain: 81X<br><br>Gearbox: Browning 107 (serial # G02K)&nbsp;<br>107SMTP35<br>Ratio-34.87<br>Sheave- 2B 3.4 SH<br>Bushing- SH 3/4<br><br>Motor: 1.5HP<br>Frame- 145T<br>Sheave- 4 1/2 OD<br>Bushing- 7/8<br><br>Guide rollers:<br>3/4" threaded rod 11" long<br>UHMW rollers 2 1/2" long 2" OD<br>2 locking collars&nbsp;<figure data-trix-attachment="{&quot;contentType&quot;:&quot;image/jpeg&quot;,&quot;filename&quot;:&quot;sortex.jpg&quot;,&quot;filesize&quot;:167734,&quot;height&quot;:2312,&quot;href&quot;:&quot;/storage/attachments/njgb4sKGkNUvqcSsmDu2G8iBwFSC6Q1V0v7BoQlL.jpg&quot;,&quot;url&quot;:&quot;/storage/attachments/njgb4sKGkNUvqcSsmDu2G8iBwFSC6Q1V0v7BoQlL.jpg&quot;,&quot;width&quot;:1734}" data-trix-content-type="image/jpeg" data-trix-attributes="{&quot;presentation&quot;:&quot;gallery&quot;}" class="attachment attachment--preview attachment--jpg"><a href="/storage/attachments/njgb4sKGkNUvqcSsmDu2G8iBwFSC6Q1V0v7BoQlL.jpg"><img src="/storage/attachments/njgb4sKGkNUvqcSsmDu2G8iBwFSC6Q1V0v7BoQlL.jpg" width="1734" height="2312"><figcaption class="attachment__caption"><span class="attachment__name">sortex.jpg</span> <span class="attachment__size">163.8 KB</span></figcaption></a></figure></div>
<div>Head Bearing: NTN P310 (UC 310-115)<br><br>Drive belt: 2 x B55<br><br>Chain: 81X<br><br>Gearbox: Browning 107 (serial # G02K)&nbsp;<br>107SMTP35<br>Ratio-34.87<br>Sheave- 2B 3.4 SH<br>Bushing- SH 3/4<br><br>Motor: 1.5HP<br>Frame- 145T<br>Sheave- 4 1/2 OD<br>Bushing- 7/8<br><br>Guide rollers:<br>3/4" threaded rod 11" long<br>UHMW rollers 2 1/2" long 2" OD<br>2 locking collars&nbsp;<figure data-trix-attachment="{&quot;contentType&quot;:&quot;image/jpeg&quot;,&quot;filename&quot;:&quot;sortex.jpg&quot;,&quot;filesize&quot;:167734,&quot;height&quot;:2312,&quot;href&quot;:&quot;/storage/attachments/njgb4sKGkNUvqcSsmDu2G8iBwFSC6Q1V0v7BoQlL.jpg&quot;,&quot;url&quot;:&quot;/storage/attachments/njgb4sKGkNUvqcSsmDu2G8iBwFSC6Q1V0v7BoQlL.jpg&quot;,&quot;width&quot;:1734}" data-trix-content-type="image/jpeg" data-trix-attributes="{&quot;presentation&quot;:&quot;gallery&quot;}" class="attachment attachment--preview attachment--jpg"><a href="/storage/attachments/njgb4sKGkNUvqcSsmDu2G8iBwFSC6Q1V0v7BoQlL.jpg"><img src="/storage/attachments/njgb4sKGkNUvqcSsmDu2G8iBwFSC6Q1V0v7BoQlL.jpg" width="1734" height="2312"><figcaption class="attachment__caption"><span class="attachment__name">sortex.jpg</span> <span class="attachment__size">163.8 KB</span></figcaption></a></figure></div>
awcodes
awcodes4w ago
You would still need to do what toeknee said, but look into using a php dom parser or php’s DOMDocument class.
morty
mortyOP4w ago
Thanks guys.

Did you find this page helpful?