[Split] Modifying post data

Discussion forum for Extension Writers regarding Extension Development.
tig_
Registered User
Posts: 23
Joined: Fri Aug 23, 2024 2:42 pm

[Split] Modifying post data

Post by tig_ »

Hi, instead of creating a new post, this one seems to be a good place for me to ask this.

I'm using an extension that enables the CKEditor to be used as the post editor. When a user drags a jpg onto the editor, CKeditor (or someone, I haven't figured out who), is inserting an img tag like this:

Code: Select all

[img]data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4ZkSRXhpZgAATU0AKgAAAAgAEAEAAAQAAAABAAAPwAEBAAQAAAABAAAL0AEPAAIAAAAHAAA...
[/img]
My board has a custom image store / upload facility that will let me take that base64 encoded data and write it as a .jpg file with an Internet accessible url, e.g. https://photos.myforum.org/<unique photo id>.jpg.

I want to trap post submit, save the base64 data as a file named `<unique photo id>.jpg` and modify the img tag above to be:

Code: Select all

[img]https://photos.myforum.org/<unique photo id>.jpg[/img]
This will enable a pretty nice photo upload capability for users.

I am trying to find docs on text_formatter_s9e_configure_after and parsers but can't find enough to really help me understand how to make this work. The closest I've found is this https://s9etextformatter.readthedocs.io ... Unparsing/

I have this code in place, ready to fill in:

Code: Select all

    static public function getSubscribedEvents()
    {
        return array(
            'core.text_formatter_s9e_configure_after'   => 'convert_img_data_to_upload'
        );
    }

    public function convert_img_data_to_upload($event)
    {
        $configurator = $event['configurator'];

        ...

    }
I'd really appreciate some pointers that will help me replace the ... above with something that lets me

- get the contents of each img tag
- replace the contents of each img tag

Thanks.

Return to “Extension Writers Discussion”