---
title: "Comment by Yuji Nakakoshi on \"CKEditor5 Image Upload - Additional thoughts\" | Hashnode"
description: "Thank you Louis, your article inspires me a lot. Because I tried to implement the image upload before this wrap-up, I took some different implementation. Let me"
url: "https://hashnode.com/posts/ckeditor5-image-upload-additional-thoughts/62dfdeb58730728f62e8e4bf/comment/62eb2fce16f9480a9dac7300"
---

[Discussion](https://hashnode.com/posts/ckeditor5-image-upload-additional-thoughts/62dfdeb58730728f62e8e4bf)

Comment [CKEditor5 Image Upload - Additional thoughts](https://hashnode.com/posts/ckeditor5-image-upload-additional-thoughts/62dfdeb58730728f62e8e4bf)

[Yuji Nakakoshi](https://hashnode.com/@ynakakoshi)

[Aug 4, 2022](https://hashnode.com/posts/ckeditor5-image-upload-additional-thoughts/62dfdeb58730728f62e8e4bf/comment/62eb2fce16f9480a9dac7300)

Thank you Louis, your article inspires me a lot.

Because I tried to implement the image upload before this wrap-up, I took some different implementation. Let me share.

Firstly the content of CKEditor stores in APEX Collection then copied to the table after Automatic-DML process by the code below.

Text is stored in CKE\_DOCUMENTS.CONTENT and CKE\_IMAGES.DOCUMENT\_ID is referring CKE\_DOCUMENTS.ID.

```
declare
    l_clob clob;
    l_link varchar2(32767);
    l_id varchar2(80);
    i pls_integer;
    l_images apex_t_varchar2;
begin
    select clob001 into l_clob
    from apex_collections where collection_name = :P2_COLLECTION and seq_id = 1;
    update cke_documents set content = l_clob where id = :P2_ID;
    -- find all image url from the content.
    i := 1;
    while true
    loop
        -- retrieve the image url with the id
        l_link := regexp_substr(l_clob, :G_IMAGE_URL || '/([0-9]+)',1,i);
        if l_link is null then
            exit;
        else
            i := i + 1;
            -- get image id from the url and remember it.
            l_id := regexp_replace(l_link, :G_IMAGE_URL || '/([0-9]+)', '\1');
            apex_string.push(l_images,l_id);
        end if;
    end loop;
    -- initialize the images linked to the document, no effect on new doc.
    update cke_images set document_id = null where document_id = :P2_ID;
    -- link image to the document.
    update cke_images set document_id = :P2_ID where id in (select column_value from table(l_images));
end;
```

Since cascade delete is enabled, any images linked to the document will be deleted along with the document. Images may remain, but housekeeping is simple (just delete the image without document\_id).

[Louis Moreaux](https://hashnode.com/@lmoreaux)

[Aug 4, 2022](https://hashnode.com/posts/ckeditor5-image-upload-additional-thoughts/62dfdeb58730728f62e8e4bf/comment/62eb2fce16f9480a9dac7300#reply-62ebd352f583cc2636e533ba)

Thank you for the comment Yuji and for sharing the solution you are using. This is awesome!
