コード例 #1
0
ファイル: ThumbnailHelper.php プロジェクト: bshaffer/Symplist
function thumbnail($img, $options = array(), $attributes = array())
{
    // Maintains Backwards Compatibility - you can pass a string or an array with [profile] set to pull
    // from YAML, or you can just pass the options in array format
    if (is_array($options)) {
        if (isset($options['profile'])) {
            $profile = $options['profile'];
            unset($options['profile']);
        } else {
            $profile = '';
        }
    } else {
        $profile = $options;
        $options = array();
    }
    //If a profile is set, pull the profile from YAML.  Else, just use the options
    //Note: you can override anything set in a profile by passing the overriden argument in options
    if ($profile) {
        $options = array_merge(getImageCacheProfile($profile), $options);
        // You can also set attributes in your imagecache profile
        if (isset($options['attributes'])) {
            $attributes = array_merge($attributes, $options['attributes']);
        }
    }
    $attributes['src'] = thumbnail_path($img, $options);
    return tag('img', $attributes);
}
コード例 #2
0
/**
 * Get thumbnail image tag
 *
 * @param  string                      $type
 * @param  Replica_ImageProxy_Abstract $proxy
 * @param  array                       $attributes - Additional tag attributes
 * @return null|string                             - Image tag
 */
function thumbnail($type, Replica_ImageProxy_Abstract $proxy, array $attributes = array())
{
    $path = thumbnail_path($type, $proxy);
    // Render tag
    if ($path) {
        $attributes['src'] = $path;
        if (!isset($attributes['alt'])) {
            $attributes['alt'] = '';
        }
        return tag('img', $attributes);
    }
}
コード例 #3
0
function get_cached_thumbnail_link($width, $link, $forced = false)
{
    global $thumbnail_directory;
    // $link をローカルファイルのパスに変換
    $src = link_to_path($link);
    // $width, $srcをチェック
    if (!preg_match("/^\\d{1,4}\$/", $width) || !file_exists($src)) {
        // 不正なら空文字列を返す
        return "";
    }
    //thumbnailのパスを決める
    $thumbnail_path = thumbnail_path($width, $src);
    if (!$forced && file_exists($thumbnail_path) && stat($thumbnail_path)["mtime"] > stat($src)["mtime"]) {
        // $forced=falseであり、かつ、
        //  キャッシュされているサムネイルが既に存在し、かつ、
        //   それが新しければ何もしない
    } else {
        // 上記以外の場合、キャッシュを生成する
        resize_image($width, $src, $thumbnail_path);
    }
    // キャッシュへのhtmlリンクを返す
    return path_to_link($thumbnail_path);
}
コード例 #4
0
ファイル: sfThumbnailHelper.php プロジェクト: net7/Talia-CMS
/**
 * Get the <img> tag to include a thumbnail into your web page
 *
 * @param string $source
 * @param int $width
 * @param int $height
 * @param mixed $options
 * @return string
 */
function thumbnail_tag($source, $width, $height, $options = array())
{
    $img_src = thumbnail_path($source, $width, $height, false);
    return image_tag($img_src, $options);
}