diff --git a/inc/documents.php b/inc/documents.php
index 0e7b3a09e968e2a40620f7b19f3da1342c689502..0eb4912e2afac15e82151be0dfe8044481e6d81e 100644
--- a/inc/documents.php
+++ b/inc/documents.php
@@ -149,8 +149,8 @@ function vignette_automatique($img, $doc, $lien, $x=0, $y=0, $align='', $class='
 
 function image_du_document($document)
 {
-	$e = $document['extension'];
-	if ((strpos($GLOBALS['meta']['formats_graphiques'], $e) !== false)
+	if ($e = $document['extension']
+	  AND (strpos($GLOBALS['meta']['formats_graphiques'], $e) !== false)
 	  AND (!test_espace_prive() OR $GLOBALS['meta']['creer_preview']=='oui')
 	  AND $document['fichier']) {
 		if ($document['distant'] == 'oui') {