slideshow.inc.php 1.9 KB

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