source: trunk/plugins/ExtendedFileManager/thumbs.php @ 579

Last change on this file since 579 was 579, checked in by ray, 8 years ago

ExtendedFileManager updates:

*to complete cofigurability through js directories can now be set for images and files individually (optional & backwards compatible)

  • relocated button from the end of toolbar next to createlink
  • insert image/link with double click
  • preview img didn't have src when no image selected, which showed a "image not found icon" in IE
  • slight modifications and updates in Readme.txt (kicked out afru's website. The domain isn't even registered anymore)
File size: 2.2 KB
Line 
1<?php
2/**
3 * On the fly Thumbnail generation.
4 * Creates thumbnails given by thumbs.php?img=/relative/path/to/image.jpg
5 * relative to the base_dir given in config.inc.php
6 * Authors: Wei Zhuo, Afru, Krzysztof Kotowicz
7 * Version: Updated on 08-01-2005 by Afru
8 * Version: Updated on 21-06-2006 by Krzysztof Kotowicz
9 * Package: ExtendedFileManager (EFM 1.1.1)
10 * http://www.afrusoft.com/htmlarea
11 */
12if(isset($_REQUEST['mode'])) $insertMode=$_REQUEST['mode'];
13if(!isset($insertMode)) $insertMode="image";
14
15require_once('config.inc.php');
16require_once('Classes/ExtendedFileManager.php');
17require_once('../ImageManager/Classes/Thumbnail.php');
18
19//check for img parameter in the url
20if(!isset($_GET['img']))
21        exit();
22
23$manager = new ExtendedFileManager($IMConfig,$insertMode);
24
25//get the image and the full path to the image
26$image = rawurldecode($_GET['img']);
27$fullpath = Files::makeFile($manager->getImagesDir(),$image);
28
29//not a file, so exit
30if(!is_file($fullpath))
31        exit();
32
33$imgInfo = @getImageSize($fullpath);
34
35//Not an image, send default thumbnail
36if(!is_array($imgInfo))
37{
38        //show the default image, otherwise we quit!
39        $default = $manager->getDefaultThumb();
40        if($default)
41        {
42                header('Location: '.$default);
43                exit();
44        }
45}
46//if the image is less than the thumbnail dimensions
47//send the original image as thumbnail
48if ($imgInfo[0] <= $IMConfig['thumbnail_width']
49 && $imgInfo[1] <= $IMConfig['thumbnail_height'])
50 {
51         header('Location: '.$manager->getFileURL($image));
52         exit();
53 }
54
55//Check for thumbnails
56$thumbnail = $manager->getThumbName($fullpath);
57if(is_file($thumbnail))
58{
59        //if the thumbnail is newer, send it
60        if(filemtime($thumbnail) >= filemtime($fullpath))
61        {
62                header('Location: '.$manager->getThumbURL($image));
63                exit();
64        }
65}
66
67//creating thumbnails
68$thumbnailer = new Thumbnail($IMConfig['thumbnail_width'],$IMConfig['thumbnail_height']);
69$thumbnailer->createThumbnail($fullpath, $thumbnail);
70
71//Check for NEW thumbnails
72if(is_file($thumbnail))
73{
74        //send the new thumbnail
75        header('Location: '.$manager->getThumbURL($image));
76        exit();
77}
78else
79{
80        //show the default image, otherwise we quit!
81        $default = $manager->getDefaultThumb();
82        if($default)
83                header('Location: '.$default);
84}
85?>
Note: See TracBrowser for help on using the repository browser.