예제 #1
0
function img($filename = '', $size_key = '', $link_uri = '', $is_link2raw_file = false, $alt = '', $is_profile = false, $is_responsive = false, $anchor_attr = array(), $img_attr = array())
{
    list($uri_path, $filename, $file_cate, $size) = img_uri($filename, $size_key, $is_profile, true);
    if (!isset($img_attr['class'])) {
        $img_attr['class'] = '';
    }
    if ($is_responsive) {
        if (!empty($img_attr['class'])) {
            $img_attr['class'] .= ' ';
        }
        $img_attr['class'] .= 'img-responsive';
    }
    if ($is_profile) {
        if (!empty($img_attr['class'])) {
            $img_attr['class'] .= ' ';
        }
        $img_attr['class'] .= 'profile_image';
    }
    if (empty($filename)) {
        $noimage_tag = Site_Util::get_noimage_tag($size, $file_cate, $img_attr);
        if ($link_uri) {
            return Html::anchor($link_uri, $noimage_tag, $anchor_attr);
        }
        return $noimage_tag;
    }
    if ($alt) {
        $img_attr['alt'] = $alt;
    }
    $image_tag = Html::img($uri_path, $img_attr);
    if ($link_uri) {
        return Html::anchor($link_uri, $image_tag, $anchor_attr);
    }
    if ($is_link2raw_file) {
        $anchor_attr['target'] = '_blank';
        $uri_path = Site_Upload::get_uploaded_file_path($filename, 'raw', 'img', false, true);
        return Html::anchor(Site_Util::get_media_uri($uri_path), $image_tag, $anchor_attr);
    }
    return $image_tag;
}