bigform/bigform_pipelines.php
2022-06-20 20:15:02 +02:00

51 lines
1.2 KiB
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 (isset($flux['args']['table'])
and $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'])
and lire_config('bigform/retailler_image') === 'oui'
) {
$url = generer_url_public("retailler_img", [
"id_document" =>intval($id_document),
"largeur" => $flux['data']['largeur'],
"hauteur" => $flux['data']['hauteur'],
"taille" => $flux['data']['taille'],
], true, false);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_exec($ch);
curl_close($ch);
}
return $flux;
}