From f8e4809a03e04fc33282745b949c00e9d9d10e89 Mon Sep 17 00:00:00 2001 From: moodler Date: Sun, 6 Oct 2002 17:20:32 +0000 Subject: [PATCH] New function print_file_picture for printing a picture from the files area, or optionally from a URL --- lib/moodlelib.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index a6802bbd72..0219cd4411 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -169,6 +169,38 @@ function print_spacer($height=1, $width=1, $br=true) { } } +function print_file_picture($path, $courseid=0, $height="", $width="", $link="") { +// Given the path to a picture file in a course, or a URL, +// this function includes the picture in the page. + global $CFG; + + if ($height) { + $height = "HEIGHT=\"$height\""; + } + if ($width) { + $width = "WIDTH=\"$width\""; + } + if ($link) { + echo ""; + } + if (substr(strtolower($path), 0, 7) == "http://") { + echo ""; + } else if ($courseid) { + echo "slasharguments) { // Use this method if possible for better caching + echo "$CFG->wwwroot/file.php/$courseid/$path"; + } else { + echo "$CFG->wwwroot/file.php?file=$courseid/$path"; + } + echo "\">"; + } else { + echo "Error: must pass URL or course"; + } + if ($link) { + echo ""; + } +} + function print_user_picture($userid, $courseid, $picture, $large=false, $returnstring=false) { global $CFG; -- 2.39.5