si c'est une image png / jpg / webm, prepare le cache image

This commit is contained in:
Christophe 2021-03-09 18:37:41 +01:00
parent f5b2f4c080
commit a8f439967e
3 changed files with 42 additions and 0 deletions

View file

@ -12,3 +12,35 @@
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;
}

View file

@ -21,5 +21,7 @@
<pipeline nom="autoriser" inclure="bigform_autorisations.php" />
<pipeline nom="declarer_tables_principales" inclure="base/bigform.php" />
<pipeline nom="post_edition" inclure="bigform_pipelines.php" />
</paquet>

8
retailler_img.html Normal file
View file

@ -0,0 +1,8 @@
#CACHE{0}
<BOUCLE_documents(DOCUMENTS){si #ENV{hash}|=={#DATE|affdate{Y-m-d}|md5}}{id_document}{tout}>
[(#FICHIER|image_recadre{3072:1800,-,focus}|adaptive_images{3072})]
[(#FICHIER|image_recadre{2048:1200,-,focus}|adaptive_images{2048})]
[(#FICHIER|image_recadre{1024:600,-,focus}|adaptive_images{1024})]
[(#FICHIER|image_recadre{512:300,-,focus}|adaptive_images{512})]
</BOUCLE_documents>