royboy789 / gutenberg-object-plugin

Saves Gutenberg data as an object / array and allows you to access it via REST API
GNU General Public License v3.0
248 stars 17 forks source link

Decode encoded strings #34

Closed mattpilott closed 3 years ago

mattpilott commented 5 years ago

I'm working with lazyblocks and i'm seeing the following:

 "editor_blocks": [{
     "uid": "418ea290-1045-4800-a03f-8aac3902de0a",
     "name": "lazyblock/hero-section",
     "data": {
         "image_left": "%7B%22alt%22:%22%22,%22title%22:%22mee%22,%22caption%22:%22%22,%22id%22:31,%22link%22:%22https://next.thechemistrygroup.com/hello-world/mee/%22,%22url%22:%22https://next.thechemistrygroup.com/app/uploads/2019/03/mee.jpg%22%7D",
         "image_right": "%7B%22alt%22:%22%22,%22title%22:%22mee%22,%22caption%22:%22%22,%22id%22:31,%22link%22:%22https://next.thechemistrygroup.com/hello-world/mee/%22,%22url%22:%22https://next.thechemistrygroup.com/app/uploads/2019/03/mee.jpg%22%7D",
         "heading": "Testingk",
         "sub_heading": "this is a test",
         "button_text": "Linky",
         "button_link": "https://google.com",
         "lazyblock": {
             "slug": "lazyblock/hero-section"
         },
         "className": "",
         "align": "",
         "anchor": "",
         "blockId": "Z2iMi8t",
         "blockUniqueClass": "lazyblock-hero-section-Z2iMi8t",
         "bid": "1c7eb"
     }
 }]

As you can see image_left and image_right are url encoded rather than an object. Perhaps there needs to be some additional formatting added to deal with this type of thing

Thanks!

royboy789 commented 5 years ago

@matt3224 for non core blocks, I'd have to add in custom formatting, since i would never know image_left or any other keys exist. I can look at Lazy blocks when I have a chance and add support, or happy to merge a PR that supports them.

Happy to help get you started down the path of support for them.