root/branches/release-26/php/lib/function.mtassetthumbnaillink.php @ 1174

Revision 1174, 1.1 kB (checked in by bchoate, 23 months ago)

Updated copyright year for source.

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    $target = "";
31    if (isset($args['new_window']))
32        $target = " target=\"_blank\"";
33
34    $asset_url = smarty_function_mtasseturl($args, $ctx);
35
36    return sprintf("<a href=\"%s\"%s><img src=\"%s\" width=\"%d\" height=\"%d\" alt=\"\" /></a>",
37        $asset_url,
38        $target,
39        $thumb,
40        $thumb_w,
41        $thumb_h);
42}
43?>
44
Note: See TracBrowser for help on using the browser.