Problem with post_insertion pipeline

Hi!
I want to add watermarks to all uploaded documents. Therefore I defined pipeline function in my plugin like this:

function watermark_post_insertion($flux) {
if ($flux[‹ args ›][‹ table ›] == ‹ spip_documents ›) {
$id_document = $flux[‹ args ›][‹ id_objet ›];
// Adding watermark here
}
}

When I had Mediathèque plugin installed, it didn’t work any way. But when I deleted Mediathèque and SPIP returned to standart uploading realiztion, function started to work.
But I met one more problem - id_objet equals to 0. This is what print_r($flux[‹ args ›]) gave me:
Array
(
[table] => spip_documents
[id_objet] => 0
)
So I have table, but I don’t have id_objet.
Here are my questions:

  1. How can I get id_objet?
  2. What whould I do when Mediathèqueplugin is installed?
  3. Maybe there is better way or already created solution on how to create watermarks on documents?

Thanks in advance.