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

Last change on this file since 522 was 521, checked in by koto, 13 years ago

Ticket #811: Added ExtendedFileManager? plugin ver 1.1.1 (with Polish translation)
Currently the plugin depends on ImageManager? class files.
Added dirSize() method used by ExtendedFileManager? to ImageManager/Classes/Files?.php

File size: 2.1 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 */
12
13require_once('config.inc.php');
14require_once('Classes/ExtendedFileManager.php');
15require_once('../ImageManager/Classes/Thumbnail.php');
16
17//check for img parameter in the url
18if(!isset($_GET['img']))
19        exit();
20
21
22$manager = new ExtendedFileManager($IMConfig);
23
24//get the image and the full path to the image
25$image = rawurldecode($_GET['img']);
26$fullpath = Files::makeFile($manager->getImagesDir(),$image);
27
28//not a file, so exit
29if(!is_file($fullpath))
30        exit();
31
32$imgInfo = @getImageSize($fullpath);
33
34//Not an image, send default thumbnail
35if(!is_array($imgInfo))
36{
37        //show the default image, otherwise we quit!
38        $default = $manager->getDefaultThumb();
39        if($default)
40        {
41                header('Location: '.$default);
42                exit();
43        }
44}
45//if the image is less than the thumbnail dimensions
46//send the original image as thumbnail
47if ($imgInfo[0] <= $IMConfig['thumbnail_width']
48 && $imgInfo[1] <= $IMConfig['thumbnail_height'])
49 {
50         header('Location: '.$manager->getFileURL($image));
51         exit();
52 }
53
54//Check for thumbnails
55$thumbnail = $manager->getThumbName($fullpath);
56if(is_file($thumbnail))
57{
58        //if the thumbnail is newer, send it
59        if(filemtime($thumbnail) >= filemtime($fullpath))
60        {
61                header('Location: '.$manager->getThumbURL($image));
62                exit();
63        }
64}
65
66//creating thumbnails
67$thumbnailer = new Thumbnail($IMConfig['thumbnail_width'],$IMConfig['thumbnail_height']);
68$thumbnailer->createThumbnail($fullpath, $thumbnail);
69
70//Check for NEW thumbnails
71if(is_file($thumbnail))
72{
73        //send the new thumbnail
74        header('Location: '.$manager->getThumbURL($image));
75        exit();
76}
77else
78{
79        //show the default image, otherwise we quit!
80        $default = $manager->getDefaultThumb();
81        if($default)
82                header('Location: '.$default);
83}
84?>
Note: See TracBrowser for help on using the repository browser.