Another Picture of the Day script

$today = (int)date('Yz');
$files = glob('*/*/thumbs/*.jpg');  // your folder structure goes here, my new one is like 2018/september/thumbs/*.jpg
$file = array_rand($files);

// open the file in a binary mode
$name = $files[$file];
$fp = fopen($name, 'rb');

// send the right headers
header("Content-Type: image/jpeg");
header("Content-Length: " . filesize($name));

// dump the picture and stop the script

Embedded like this:

<img src="oftheday.php" alt="[img]">

(If you need to display EXIF information or link to the original image, see this script instead.)

About dotcomboom

Software developer, photographer... blogger...?
This entry was posted in Other Projects, Tutorials and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.