image rotation in twitter card

master
Pentomino 2019-04-09 15:58:26 +02:00
parent d2a8d19f15
commit bb5522a1be
2 changed files with 35 additions and 1 deletions

View File

@ -15,7 +15,7 @@
<meta name="twitter:site" content="@Level2Lu">
<meta name="twitter:title" content="Level2 | a hackerspace in Luxembourg City">
<meta name="twitter:description" content="Check out whether we're open, how many people are present right now or what events are scheduled to happen at our place. Swing by to say hello and become a member if you like to =]">
<meta name="twitter:image" content="https://files.level2.lu/photos/twitterCard.jpg">
<meta name="twitter:image" content="https://files.level2.lu/photos/twitterCard.php">
{% endblock twitterCard %}
<title>Level2{% block title %}{% endblock title %}</title>

34
twitterCard.php Normal file
View File

@ -0,0 +1,34 @@
<?PHP
# stackexchange2php("https://stackoverflow.com/questions/15151051/url-to-a-random-image")
function random_pic($dir = 'imagerotation') {
$files = glob($dir . '/*.jpg');
if (!$files) return false;
$file = array_rand($files);
return $files[$file];
}
function outputImage( $filename ) {
header('Content-Description: File Transfer');
header("Content-type: image/jpeg");
# header('Content-Disposition: attachment; filename='.basename($filename ));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($filename ));
ob_clean();
flush();
readfile($filename );
exit;
}
// Get a filename
$filename=random_pic();
// Check that a file was found
if (!$filename) {
header('HTTP/1.0 404 Not Found');
die();
}
// Output the image
outputImage( $filename );
?>