예제 #1
0
function lazyThumbnail($url, $href = false)
{
    $t = computeThumbnail($url, $href);
    if (count($t) == 0) {
        return '';
    }
    // Empty array = no thumbnail for this URL.
    $html = '<a href="' . escape($t['href']) . '">';
    // Lazy image
    $html .= '<img class="b-lazy" src="#" data-src="' . escape($t['src']) . '"';
    if (!empty($t['width'])) {
        $html .= ' width="' . escape($t['width']) . '"';
    }
    if (!empty($t['height'])) {
        $html .= ' height="' . escape($t['height']) . '"';
    }
    if (!empty($t['style'])) {
        $html .= ' style="' . escape($t['style']) . '"';
    }
    if (!empty($t['alt'])) {
        $html .= ' alt="' . escape($t['alt']) . '"';
    }
    $html .= '>';
    // No-JavaScript fallback.
    $html .= '<noscript><img src="' . escape($t['src']) . '"';
    if (!empty($t['width'])) {
        $html .= ' width="' . escape($t['width']) . '"';
    }
    if (!empty($t['height'])) {
        $html .= ' height="' . escape($t['height']) . '"';
    }
    if (!empty($t['style'])) {
        $html .= ' style="' . escape($t['style']) . '"';
    }
    if (!empty($t['alt'])) {
        $html .= ' alt="' . escape($t['alt']) . '"';
    }
    $html .= '></noscript></a>';
    return $html;
}
예제 #2
0
function lazyThumbnail($url, $href = false)
{
    $t = computeThumbnail($url, $href);
    if (count($t) == 0) {
        return '';
    }
    // Empty array = no thumbnail for this URL.
    $html = '<a href="' . htmlspecialchars($t['href']) . '">';
    // Lazy image (only loaded by javascript when in the viewport).
    $html .= '<img class="lazyimage" src="#" data-original="' . htmlspecialchars($t['src']) . '"';
    if (!empty($t['width'])) {
        $html .= ' width="' . htmlspecialchars($t['width']) . '"';
    }
    if (!empty($t['height'])) {
        $html .= ' height="' . htmlspecialchars($t['height']) . '"';
    }
    if (!empty($t['style'])) {
        $html .= ' style="' . htmlspecialchars($t['style']) . '"';
    }
    if (!empty($t['alt'])) {
        $html .= ' alt="' . htmlspecialchars($t['alt']) . '"';
    }
    $html .= '>';
    // No-javascript fallback:
    $html .= '<noscript><img src="' . htmlspecialchars($t['src']) . '"';
    if (!empty($t['width'])) {
        $html .= ' width="' . htmlspecialchars($t['width']) . '"';
    }
    if (!empty($t['height'])) {
        $html .= ' height="' . htmlspecialchars($t['height']) . '"';
    }
    if (!empty($t['style'])) {
        $html .= ' style="' . htmlspecialchars($t['style']) . '"';
    }
    if (!empty($t['alt'])) {
        $html .= ' alt="' . htmlspecialchars($t['alt']) . '"';
    }
    $html .= '></noscript></a>';
    return $html;
}