function process_form() { $angle = required_param('angle', PARAM_INT); $info = lightboxgallery_image_info($this->imagepath); if ($im = lightboxgallery_imagecreatefromtype($info->imagesize[2], $this->imagepath)) { $rotated = imagerotate($im, $angle, 0); $this->save_image_resource($rotated, $info->imagesize[2]); } }
function output() { $info = lightboxgallery_image_info($this->imagepath); $result = get_string('selectthumbpos', 'lightboxgallery') . '<br /><br />'; if ($info->imagesize[0] < $info->imagesize[1]) { $result .= '<label><input type="radio" name="move" value="1" />' . get_string('dirup', 'lightboxgallery') . '</label> ' . '<label><input type="radio" name="move" value="2" />' . get_string('dirdown', 'lightboxgallery') . '</label>'; } else { $result .= '<label><input type="radio" name="move" value="3" />' . get_string('dirleft', 'lightboxgallery') . '</label> ' . '<label><input type="radio" name="move" value="4" />' . get_string('dirright', 'lightboxgallery') . '</label>'; } $result .= '<br /><br />' . get_string('thumbnailoffset', 'lightboxgallery') . ': <input type="text" name="offset" value="20" size="4" /><br /><br />' . '<input type="submit" value="' . get_string('move') . '" /> <input type="submit" name="reset" value="' . get_string('reset') . '" />'; return $this->enclose_in_form($result); }
function process_form() { $x1 = required_param('x1', PARAM_INT); $y1 = required_param('y1', PARAM_INT); $x2 = required_param('x2', PARAM_INT); $y2 = required_param('y2', PARAM_INT); $width = $x2 - $x1; $height = $y2 - $y1; $info = lightboxgallery_image_info($this->imagepath); if ($width > 0 && $height > 0) { if ($image = lightboxgallery_imagecreatefromtype($info->imagesize[2], $this->imagepath)) { $cropped = lightboxgallery_image_create($width, $height); imagecopybicubic($cropped, $image, 0, 0, $x1, $y1, $width, $height, $width, $height); $this->save_image_resource($cropped, $info->imagesize[2]); } } }
function process_form() { $button = required_param('button', PARAM_TEXT); switch ($button) { case $this->buttonresize: $size = required_param('size', PARAM_INT); list($width, $height) = explode('x', $this->resizeoptions[$size]); break; case $this->buttonscale: $scale = required_param('scale', PARAM_INT); $imagesize = getimagesize($this->imagepath); $width = $imagesize[0] * ($scale / 100); $height = $imagesize[1] * ($scale / 100); break; } $info = lightboxgallery_image_info($this->imagepath); if ($im = lightboxgallery_imagecreatefromtype($info->imagesize[2], $this->imagepath)) { $resized = lightboxgallery_resize_image($im, $info, $width, $height); $this->save_image_resource($resized, $info->imagesize[2]); } }
function process_form() { global $CFG; $mode = required_param('mode', PARAM_INT); $info = lightboxgallery_image_info($this->imagepath); $w = $info->imagesize[0]; $h = $info->imagesize[1]; if ($im = lightboxgallery_imagecreatefromtype($info->imagesize[2], $this->imagepath)) { $truecolor = (function_exists('ImageCreateTrueColor') and $CFG->gdversion >= 2); $flipped = $truecolor ? ImageCreateTrueColor($w, $h) : ImageCreate($w, $h); if ($mode & FLIP_VERTICAL) { if ($truecolor) { for ($x = 0; $x < $w; $x++) { for ($y = 0; $y < $h; $y++) { imagecopy($flipped, $im, $w - $x - 1, $y, $x, $y, 1, 1); } } } else { for ($y = 0; $y < $h; $y++) { imagecopy($flipped, $im, 0, $y, 0, $h - $y - 1, $w, 1); } } } if ($mode & FLIP_HORIZONTAL) { if ($truecolor) { for ($x = 0; $x < $w; $x++) { for ($y = 0; $y < $h; $y++) { imagecopy($flipped, $im, $x, $h - $y - 1, $x, $y, 1, 1); } } } else { for ($x = 0; $x < $w; $x++) { imagecopy($flipped, $im, $x, 0, $w - $x - 1, 0, 1, $h); } } } $this->save_image_resource($flipped, $info->imagesize[2]); } }
$textlib = textlib_get_instance(); $edittypes = $editing ? lightboxgallery_edit_types() : null; foreach ($images as $image) { $imageextra = ''; $imageurl = $webroot . '/' . $image; $imagelocal = $dataroot . '/' . $image; $imagelabel = $textlib->strlen($image) > MAX_IMAGE_LABEL ? $textlib->substr($image, 0, MAX_IMAGE_LABEL) . '...' : $image; if ($edittypes) { $imageextra = '<form action="' . $CFG->wwwroot . '/mod/lightboxgallery/imageedit.php" method="get">' . '<input type="hidden" name="id" value="' . $gallery->id . '" />' . '<input type="hidden" name="image" value="' . $image . '" />' . '<input type="hidden" name="page" value="' . $page . '" />' . '<select name="tab" class="lightbox-edit-select" onchange="submit();">' . '<option>' . get_string('choose') . '...</option>'; foreach ($edittypes as $editoption => $editdisplay) { $imageextra .= '<option value="' . $editoption . '">' . $editdisplay . '</option>'; } $imageextra .= '</select></form>'; } else { if ($gallery->extinfo) { $iobj = lightboxgallery_image_info($imagelocal); $imageextra = sprintf('<br />%s<br />%s, %dx%d', $iobj->modified, $iobj->filesize, $iobj->imagesize[0], $iobj->imagesize[1]); } } $imagetitle = isset($captions[$image]) ? $captions[$image] : $image; echo '<div class="lightboxgalleryimage" style="float:right;padding:7px;"><a href="' . $imageurl . '" rel="lightbox[' . $gallery->name . ']" title="' . $imagetitle . '">' . lightboxgallery_image_thumbnail($course->id, $gallery, $image) . '</a><br />' . $imagelabel . $imageextra . '</div>'; } } else { print_string('errornoimages', 'lightboxgallery'); } print_simple_box_end(); if ($gallery->perpage) { print_paging_bar(count($allimages), $page, $gallery->perpage, $CFG->wwwroot . '/mod/lightboxgallery/view.php?id=' . $cm->id . '&' . ($editing ? 'editing=1&' : '')); } $showtags = !in_array('tag', explode(',', get_config('lightboxgallery', 'disabledplugins'))); if (!$editing && $showtags) {
function lightboxgallery_image_thumbnail($courseid, $gallery, $file, $offsetx = 0, $offsety = 0) { global $CFG; // If anything fails when retrieving the thumbnail, we'll fallback to just printing a label $fallback = '[' . $file . ']'; $oldpath = $CFG->dataroot . '/' . $courseid . '/' . $gallery->folder . '/' . $file; $newpath = $courseid . '/' . $gallery->folder . '/_thumb/' . $file . '.jpg'; if (empty($CFG->gdversion)) { return $fallback; } umask(00); if (file_exists($CFG->dataroot . '/' . $newpath)) { return lightboxgallery_make_img(lightboxgallery_get_image_url($gallery->id, $file, true)); } else { $thumbdir = $CFG->dataroot . '/' . dirname($newpath); if (!file_exists($thumbdir) && !mkdir($thumbdir, $CFG->directorypermissions)) { return $fallback; } } $info = lightboxgallery_image_info($oldpath); if (!($im = lightboxgallery_imagecreatefromtype($info->imagesize[2], $oldpath))) { return $fallback; } $thumb = lightboxgallery_resize_image($im, $info, THUMB_WIDTH, THUMB_HEIGHT, $offsetx, $offsety); if (function_exists('ImageJpeg')) { @touch($CFG->dataroot . '/' . $newpath); if (ImageJpeg($thumb, $CFG->dataroot . '/' . $newpath, 90)) { @chmod($CFG->dataroot . '/' . $newpath, 0666); return lightboxgallery_make_img(lightboxgallery_get_image_url($gallery->id, $file, true)); } } else { return $fallback; } }
if (isset($formdata->caption) && trim($formdata->caption) != '') { lightboxgallery_set_image_caption($gallery->id, $filename, $formdata->caption); $messages[] = get_string('edit_caption', 'lightboxgallery') . ': ' . $formdata->caption; } $resizeoption = 0; if (in_array($gallery->autoresize, array(AUTO_RESIZE_UPLOAD, AUTO_RESIZE_BOTH))) { $resizeoption = $gallery->resize; } else { if (isset($formdata->resize)) { $resizeoption = $formdata->resize; } } if ($resizeoption > 0) { $resizeoptions = lightboxgallery_resize_options(); $fullpath = $CFG->dataroot . '/' . $uploaddir . '/' . $filename; $info = lightboxgallery_image_info($fullpath); if ($im = lightboxgallery_imagecreatefromtype($info->imagesize[2], $fullpath)) { list($width, $height) = explode('x', $resizeoptions[$resizeoption]); if ($resized = lightboxgallery_resize_image($im, $info, $width, $height)) { switch ($info->imagesize[2]) { case 1: $function = 'ImageGIF'; break; case 2: $function = 'ImageJPEG'; break; case 3: $function = 'ImagePNG'; break; } if (function_exists($function)) {