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