slideshow.inc.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @author Patrick Cool
  5. * @package chamilo.document
  6. * @todo convert comments to be understandable to phpDocumentor
  7. */
  8. /*
  9. Description:
  10. This is a plugin for the documents tool. It looks for .jpg, .jpeg, .gif, .png
  11. files (since these are the files that can be viewed in a browser) and creates
  12. a slideshow with it by allowing to go to the next/previous image.
  13. You can also have a quick overview (thumbnail view) of all the images in
  14. that particular folder.
  15. Maybe it is important to notice that each slideshow is folder based. Only
  16. the images of the chosen folder are shown.
  17. This file has two large sections.
  18. 1. code that belongs in document.php, but to avoid clutter I put the code here
  19. 2. the function resize_image that handles the image resizing
  20. */
  21. /**
  22. * This function calculates the resized width and resized heigt according to the source and target widths
  23. * and heights, height so that no distortions occur
  24. * parameters
  25. * $image = the absolute path to the image
  26. * $target_width = how large do you want your resized image
  27. * $target_height = how large do you want your resized image
  28. * $slideshow (default=0) = indicates weither we are generating images for a slideshow or not, t
  29. * this overrides the $_SESSION["image_resizing"] a bit so that a thumbnail
  30. * view is also possible when you choose not to resize the source images
  31. */
  32. function resize_image($image, $target_width, $target_height, $slideshow = 0) {
  33. // Modifications by Ivan Tcholakov, 04-MAY-2009.
  34. $result = array();
  35. if ($_SESSION['image_resizing'] == 'resizing' or $slideshow == 1) {
  36. $new_sizes = api_resize_image($image, $target_width, $target_height);
  37. $result[] = $new_sizes['height'];
  38. $result[] = $new_sizes['width'];
  39. } else {
  40. $size = api_getimagesize($image);
  41. $result[] = $size['height'];
  42. $result[] = $size['width'];
  43. }
  44. return $result;
  45. }