Skip to content

Commit

Permalink
New function print_file_picture for printing a picture from the
Browse files Browse the repository at this point in the history
files area, or optionally from a URL
  • Loading branch information
moodler committed Oct 6, 2002
1 parent 14d8c0b commit f8e4809
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit f8e4809

Please sign in to comment.