login/edit: refresh thumbnails on avatar upload
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 16 Jun 2018 19:49:57 +0000 (21:49 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 16 Jun 2018 19:58:29 +0000 (21:58 +0200)
login/edit.php

index cfbc2d7b82c2eebd725830bf0c9f4f4508132a8e..9611c7d8ba85a5cb25d820ff8f7c74a3f443e13e 100644 (file)
@@ -85,6 +85,10 @@ if ($_POST) {
                if (!@move_uploaded_file($val['tmp_name'], $cols[$col]['target'])) {
                        $colwarn[$col] = "Fout bij opslaan.";
                }
+               foreach (@glob('thumb/*/') as $thumbres) {
+                       # attempt to remove old derivations
+                       @unlink($thumbres.'/'.$cols[$col]['target']);
+               }
                $cols[$col]['value'] = '';
        }
 
@@ -115,9 +119,9 @@ foreach ($cols as $col => &$colconf) {
        print "\t";
        printf('<li><label for="%s">%s:</label>', $col, ucfirst($colconf['label']));
        if (@$colconf['type'] == 'file' and isset($colconf['value'])) {
-               printf('<a href="/%s"><img src="/thumb/%s/%s" /></a><br />',
+               printf('<a href="/%s"><img src="/thumb/%s/%s?%s" /></a><br />',
                        $colconf['target'],
-                       200, $colconf['target']
+                       200, $colconf['target'], filemtime($colconf['target'])
                );
        }
        print "<input";