Community Documentation

Snippet to display a different image for each day of the week

Last updated October 6, 2006. Created by Dublin Drupaller on April 29, 2006.
Edited by pwolanin. Log in to edit this page.

PLEASE NOTE: The php snippets are user submitted and it is impossible to check every one, so use at your own risk. For users who have setup drupal using an alternate database to the default, please note that the snippets may contain some database queries that may or may not work.

The following snippet displays a specific image depending on the day of the wee

<?php
/**
* The following displays a specific image depending
* on the day of the week
*
* Simple to use, just name your graphics to be Monday.jpg,
* Tuesday.jpg, Wednesday.jpg etc. upoad them to
* a /daily_images/ folder and paste this php snippet into
* a block/page/front_page  and remember to select
* PHP INPUT FILTER
*
* Note: when naming your images, capitalise the spelling
* Monday.jpg, Tuesday.jpg, Wednesday.jpg, Thursday.jpg  etc.
*
* Dublin Drupaller: Tested and works with Drupal 4.5, 4.6 and 4.7
*/

// Change the path and file type to suit.
$image_folder = "daily_images";
$file_type = ".jpg";
$today = date('l');
$image_name = $today . $file_type;
print
"<img src=\"$image_folder/$image_name\" alt=\"put some text here\" />";
?>

About this page

Drupal version
Drupal 4.5.x or older, Drupal 4.6.x, Drupal 4.7.x

Reference

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.