Manuel:Thumb handler.php
Jump to navigation
Jump to search
Outdated translations are marked like this.
fichier de MediaWiki : thumb_handler.php | |
---|---|
Emplacement : | / |
Code source : | master • 1.35.1 • 1.31.12 |
Classes : | Accès au code • Accès à la documentation |
Description
thumb_handler.php est un script utilisé pour redimensionner automatiquement les images d'un gestionnaire 404 . Par exemple, quand un navigateur demande une vignette qui n'a pas été créée précédemment.
Pour l'utiliser, suivez les étapes ci-dessous, puis initialisez $GenerateThumbnailOnParse à false
. Si vous avez défini $wgLocalFileRepo dans LocalSettings.php, alors vous devez également initialiser :
$wgLocalFileRepo['transformVia404'] = true;
Configuration du serveur
Apache
Créez une règle de réécriture pour appeler thumb_handler.php lorsqu'un fichier de $wgUploadPath /thumb/ n'existe pas. Si votre wiki est dans le répertoire /w , quelque chose de similaire à cela devrait fonctionner :
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/?w/images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/[^/]+/[^/]+$ /w/thumb_handler.php [L,QSA]
# If your $wgHashedUploadDirectory is false, remove the first two steps after thumb/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/?w/images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/[^/]+/[^/]+$ /w/thumb_handler.php [L,QSA]
# If your $wgHashedUploadDirectory is false, remove the first two steps after thumb/archive/
nginx
location /wiki/images {
# Separate location for images/ so .php execution won't apply
location ~ ^/w/images/thumb/(archive/)?[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/[^/]*([0-9]+)px-.*$ {
# Thumbnail handler for MediaWiki
# This location only matches on a thumbnail's url
# If the file does not exist we use @thumb to run the thumb.php script
try_files $uri $uri/ @thumb;
}
}
# Thumbnail 404 handler, only called by try_files when a thumbnail does not exist
location @thumb {
# Do a rewrite here so that thumb.php gets the correct arguments
rewrite ^/w/images/thumb/([0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/[^/]*([0-9]+)px-.*)$ /w/thumb_handler.php/$1;
rewrite ^/w/images/thumb/(archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/[^/]*([0-9]+)px-.*)$ /w/thumb_handler.php/$1;
}