root/branches/release-41/php/lib/function.mtassetthumbnaillink.php @ 2651

Revision 2651, 1.2 kB (checked in by takayama, 17 months ago)

Fixed BugId:80372
* Shows warning messages if GD-php was not available.

Line 
1<?php
2# Movable Type (r) Open Source (C) 2001-2008 Six Apart, Ltd.
3# This program is distributed under the terms of the
4# GNU General Public License, version 2.
5#
6# $Id$
7
8require_once("function.mtasseturl.php");
9function smarty_function_mtassetthumbnaillink($args, &$ctx) {
10    $asset = $ctx->stash('asset');
11    if (!$asset) return '';
12    if ($asset['asset_class'] != 'image') return '';
13    $blog = $ctx->stash('blog');
14    if (!$blog) return '';
15
16    require_once('MTUtil.php');
17
18    $width = 0;
19    $height = 0;
20    $scale = 0;
21
22    if (isset($args['width']))
23        $width = $args['width'];
24    if (isset($args['height']))
25        $height = $args['height'];
26    if (isset($args['scale']))
27        $scale = $args['scale'];
28
29    list($thumb, $thumb_w, $thumb_h) = get_thumbnail_file($asset, $blog, $width, $height, $scale);
30    if (empty($thumb)) {
31        return '';
32    }
33
34    $target = "";
35    if (isset($args['new_window']))
36        $target = " target=\"_blank\"";
37
38    $asset_url = smarty_function_mtasseturl($args, $ctx);
39
40    return sprintf("<a href=\"%s\"%s><img src=\"%s\" width=\"%d\" height=\"%d\" alt=\"\" /></a>",
41        $asset_url,
42        $target,
43        $thumb,
44        $thumb_w,
45        $thumb_h);
46}
47?>
48
Note: See TracBrowser for help on using the browser.