bigform/bigform_pipelines.php

46 lines
948 B
PHP

<?php
/**
* Utilisations de pipelines par BigForm
*
* @plugin BigForm
* @copyright 2019
* @author tofulm
* @licence GNU/GPL
* @package SPIP\Bigform\Pipelines
*/
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
/**
* Branchement sur l'insertion de document pour generer le cache des images
* a la sortie du formualire
* Extensions utilisées :
* - jpg
* - png
* - webm
*
* @param Array $flux
*
* @return Array $flux
*/
function bigform_post_edition($flux){
if (
$flux['args']['table'] === 'spip_documents'
and $id_document = intval($flux['args']['id_objet'])
and $flux['args']['action'] === 'ajouter_document'
and in_array($flux['data']['extension'], ['jpg', 'png', 'webm'])
) {
$url = generer_url_public("retailler_img", [
"id_document" =>intval($id_document),
"hash" => md5(date("Y-m-d"))
], true, false);
$ch = curl_init($url);
curl_exec($ch);
curl_close($ch);
}
return $flux;
}