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

Revision 2651, 1.1 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
8function smarty_function_mtcommenteruserpic($args, &$ctx) {
9    $comment = $ctx->stash('comment');
10    if (!$comment) {
11        return $ctx->error("No comment available");
12    }
13    $cmntr = $ctx->stash('commenter');
14    if (!$cmntr) return '';
15
16    $asset_id = isset($cmntr['author_userpic_asset_id']) ? $cmntr['author_userpic_asset_id'] : 0;
17    $asset = $ctx->mt->db->fetch_assets(array('id' => $asset_id));
18    if (!$asset) return '';
19
20    $blog =& $ctx->stash('blog');
21
22    require_once("MTUtil.php");
23    $userpic_url = userpic_url($asset[0], $blog, $cmntr);
24    if (empty($userpic_url))
25        return '';
26
27    $asset_path = asset_path($asset[0]['asset_file_path'], $blog);
28    list($src_w, $src_h, $src_type, $src_attr) = getimagesize($asset_path);
29    $dimensions = sprintf('width="%s" height="%s"', $src_w, $src_h);
30
31    $link =sprintf('<img src="%s" %s alt="%s" />',
32                   encode_html($userpic_url), $dimensions, encode_html($asset['label']));
33
34    return $link;
35}
36?>
Note: See TracBrowser for help on using the browser.