1 | <?php |
---|
2 | /***************************************\ |
---|
3 | | PHP OPTIMISATEUR | |
---|
4 | | Plugin Front2Back Support 1.2 | |
---|
5 | \***************************************/ |
---|
6 | |
---|
7 | ## Déplace les versions alternatives dans 'thumbnail/verso' |
---|
8 | ## Crée la version alternative hd dans 'pwg_high/verso' |
---|
9 | ## Supprime le suffixe et déplace aussi les fichiers du repertoire source |
---|
10 | |
---|
11 | $F2B_nameverso = $CONF['Plugins']['front2back_support']['NAMEverso']; // Suffixe des versions alternatives |
---|
12 | $F2B_moveverso = $CONF['Plugins']['front2back_support']['MOVEverso']; // Déplacer les images originales dans un sous dosssier 'verso' |
---|
13 | $F2B_tagverso = $CONF['Plugins']['front2back_support']['TAGverso']; // Ajoute un tag à toutes les images possédant une version alternative |
---|
14 | |
---|
15 | if (!isset($BlockAll)) { |
---|
16 | |
---|
17 | // applique le tag au fichier normal si il existe un verso |
---|
18 | if (file_exists($file['folder_src'].$file['name'].$F2B_nameverso.'.'.$file['ext']) AND !empty($F2B_tagverso)) { |
---|
19 | nconvert('-iptc_add 25 "'.$F2B_tagverso.'" "'.$FilesSource[$i].'"'); |
---|
20 | $LOG[] = 'Tag "'.$F2B_tagverso.'" added to '.$FilesSource[$i]; |
---|
21 | } |
---|
22 | |
---|
23 | if (strpos($file['name'], $F2B_nameverso) !== false) { |
---|
24 | $file['name_clean'] = str_replace($F2B_nameverso,null,$file['name']); |
---|
25 | |
---|
26 | if (!empty($F2B_tagverso)) { |
---|
27 | nconvert('-iptc_add 25 "'.$F2B_tagverso.'" "'.$FilesSource[$i].'"'); |
---|
28 | $LOG[] = 'Tag "'.$F2B_tagverso.'" added to '.$FilesSource[$i]; |
---|
29 | } |
---|
30 | |
---|
31 | // Image normale |
---|
32 | if (!file_exists($file['folder_out'].'thumbnail/verso')) { |
---|
33 | mkdir_log($file['folder_out'].'thumbnail/verso'); |
---|
34 | } |
---|
35 | nconvert('-q '.$CONF['Qnormal'].' -out jpeg -o "'.$file['folder_out'].'thumbnail/verso/'.$file['name_clean'].'.jpg" -dpi 72 '.$CONF['convOptions'].' -resize '.$CONF['DIMnormal'].' '.$CONF['DIMnormal'].' '.$CONF['copyNormal'].' "'.$FilesSource[$i].'"'); |
---|
36 | |
---|
37 | // Image hd |
---|
38 | if ($CONF['DIRhighORNOT']) { |
---|
39 | if (!file_exists($file['folder_out'].'pwg_high/verso')) { |
---|
40 | mkdir($file['folder_out'].'pwg_high/verso'); |
---|
41 | $LOG[] = 'Dir '.$file['folder_out'].'pwg_high/verso/ created'; |
---|
42 | } |
---|
43 | if ($CONF['DIMhdORNOT']) { |
---|
44 | nconvert('-q '.$CONF['Qhd'].' -out jpeg -o "'.$file['folder_out'].'pwg_high/verso/'.$file['name_clean'].'.jpg" -dpi '.$CONF['DPI'].' '.$CONF['convOptions'].' -resize '.$CONF['DIMhd'].' '.$CONF['DIMhd'].' '.$CONF['copyHD'].' "'.$FilesSource[$i].'"'); |
---|
45 | } else if (strtolower($file['ext']) != 'jpg') { |
---|
46 | nconvert('-q '.$CONF['Qhd'].' -out jpeg -o "'.$file['folder_out'].'pwg_high/'.$file['name_clean'].'.jpg" "'.$FilesSource[$i].'"'); |
---|
47 | } else { |
---|
48 | copy_log($FilesSource[$i], $file['folder_out'].'pwg_high/verso/'.$file['name_clean'].'.jpg'); |
---|
49 | } |
---|
50 | } |
---|
51 | |
---|
52 | // Déplacement de l'image originale |
---|
53 | if ($F2B_moveverso) { |
---|
54 | if (!file_exists($file['folder_src'].'verso')) { |
---|
55 | mkdir_log($file['folder_src'].'verso', 0777, true); |
---|
56 | } |
---|
57 | rename_log($file['folder_src'].$file['name'].'.'.$file['ext'], $file['folder_src'].'verso/'.$file['name_clean'].'.'.$file['ext'], true); |
---|
58 | } |
---|
59 | |
---|
60 | // Suppression de la miniature si déjà crée (par un autre plugin) |
---|
61 | if (file_exists($file['folder_out'].'thumbnail/'.$CONF['prefixe_mini'].$file['name'].'.jpg')) { |
---|
62 | unlink($file['folder_out'].'thumbnail/'.$CONF['prefixe_mini'].$file['name'].'.jpg'); |
---|
63 | } |
---|
64 | // Suppression de l'image HD si déjà crée (par un autre plugin) |
---|
65 | if (file_exists($file['folder_out'].'pwg_high/'.$file['name'].'.jpg')) { |
---|
66 | unlink($file['folder_out'].'pwg_high/'.$file['name'].'.jpg'); |
---|
67 | } |
---|
68 | |
---|
69 | $BlockNormal['front2back_support'] = true; |
---|
70 | $BlockThumbnail['front2back_support'] = true; |
---|
71 | $BlockHigh['front2back_support'] = true; |
---|
72 | } |
---|
73 | |
---|
74 | } |
---|
75 | ?> |
---|