Skip to content
Browse files

New function print_file_picture for printing a picture from the

files area, or optionally from a URL
  • Loading branch information...
1 parent 14d8c0b commit f8e4809a03e04fc33282745b949c00e9d9d10e89 moodler committed Oct 6, 2002
Showing with 32 additions and 0 deletions.
  1. +32 −0 lib/moodlelib.php
View
32 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 "<A HREF=\"$link\">";
+ }
+ if (substr(strtolower($path), 0, 7) == "http://") {
+ echo "<IMG BORDER=0 $height $width SRC=\"$path\">";
+ } else if ($courseid) {
+ echo "<IMG BORDER=0 $height $width SRC=\"";
+ if ($CFG->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 "</A>";
+ }
+}
+
function print_user_picture($userid, $courseid, $picture, $large=false, $returnstring=false) {
global $CFG;

0 comments on commit f8e4809

Please sign in to comment.
Something went wrong with that request. Please try again.