Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Plugin Dev: Catching the upload as an event? Upload by any editor.

0 votes
772 views
asked Sep 21, 2014 in Plugins by q2apro

Hi all, for a new plugin I am devleoping I thought I could catch the image upload somehow. My plugin needs to collect all Blobids from all uploaded files this day, though, I am think about a mysql workaround now. Nevertheless, the question is quite interesting for developers and upcoming plugins.

Each editor uses a URL for the upload. So I could look for the matching request like that:

        function match_request($request)
        {
            return ($request=='sceditor-upload'); // or another editor URL
        }
 

Problem is that each plugin has another $request URL. So using my plugin I do not know what the editor URL is and cannot catch the upload "event".

Any idea how to overcome this?

Thanks,
Kai

 

For reference: http://www.question2answer.org/modules.php

Q2A version: 1.6.3

1 Answer

+1 vote
answered Oct 11, 2014 by fine129
edited Oct 11, 2014 by fine129
I am also working to add more custom events .

For now I think you can override qa_create_blob (in qa-app-blobs.php line 66) and qa_db_blob_create (in qa-db-blobs.php line 33)

Then you can use qa_report_event to report any custom events with any additional data.

Hope it may be helpful.
commented Oct 11, 2014 by q2apro
Nice idea, I didn't think of that :)
commented Oct 11, 2014 by pupi1985
edited Oct 11, 2014 by pupi1985
But if you're talking about editors then you mean uploading from situations in which you are posting. Those functions handle all blob creations, not only the ones for posts. EG: Uploading an avatar.
commented Oct 11, 2014 by fine129
I think there may be some workrounds. He can test other events like q_post in some places.
...