Changeset 13444


Ignore:
Timestamp:
Feb 29, 2012, 10:21:46 PM (9 years ago)
Author:
patdenice
Message:

Multisize
Load thumbnails with ajax.

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/i.php

    r13426 r13444  
    320320{
    321321  global $page;
     322
     323  if (isset($_GET['ajaxload']) and $_GET['ajaxload'] == 'true')
     324  {
     325    include_once(PHPWG_ROOT_PATH.'include/functions_cookie.inc.php');
     326    include_once(PHPWG_ROOT_PATH.'include/functions_url.inc.php');
     327
     328    $response = new json_response();
     329    $response->url = embellish_url(get_absolute_root_url().$page['derivative_path']);
     330    echo json_encode($response);
     331    return;
     332  }
    322333  $fp = fopen($page['derivative_path'], 'rb');
    323334
     
    344355}
    345356
     357class json_response
     358{
     359  var $url;
     360}
    346361
    347362$page=array();
     
    401416  }
    402417  send_derivative($expires);
     418  exit;
    403419}
    404420
  • trunk/include/derivative.inc.php

    r13252 r13444  
    100100
    101101  private $params;
    102   private $rel_path, $rel_url;
     102  private $rel_path, $rel_url, $is_cached;
    103103
    104104  function __construct($type, $src_image)
     
    114114    }
    115115
    116     self::build($src_image, $this->params, $this->rel_path, $this->rel_url);
     116    self::build($src_image, $this->params, $this->rel_path, $this->rel_url, $this->is_cached);
    117117  }
    118118
     
    154154  }
    155155
    156   private static function build($src, &$params, &$rel_path, &$rel_url)
     156  private static function build($src, &$params, &$rel_path, &$rel_url, &$is_cached=null)
    157157  {
    158158    if ( $src->has_size() && $params->is_identity( $src->get_size() ) )
     
    161161      $params = null;
    162162      $rel_path = $rel_url = $src->rel_path;
     163      $is_cached = true;
    163164      return;
    164165    }
     
    192193      if ($mtime===false or $mtime < $params->last_mod_time)
    193194      {
     195        $is_cached = false;
    194196        $url_style = 2;
    195197      }
    196198      else
    197199      {
     200        $is_cached = true;
    198201        $url_style = 1;
    199202      }
     
    304307    }
    305308  }
     309
     310  function is_cached()
     311  {
     312    return $this->is_cached;
     313  }
    306314}
    307315
  • trunk/themes/default/template/thumbnails.tpl

    r12958 r13444  
    11{if !empty($thumbnails)}{strip}
     2{combine_script id='jquery.ajaxmanager' path='themes/default/js/plugins/jquery.ajaxmanager.js' load='async'}
     3{combine_script id='thumbnails.loader' path='themes/default/js/thumbnails.loader.js' require='jquery.ajaxmanager' load='async'}
    24{*define_derivative name='derivative_params' width=160 height=90 crop=true*}
    35{html_style}
     
    2325{/html_style}
    2426{foreach from=$thumbnails item=thumbnail}
     27{assign var=derivative value=$pwg->derivative($derivative_params, $thumbnail.src_image)}
    2528        <li>
    2629        <span class="wrap1">
    2730                <span class="wrap2">
    2831                <a href="{$thumbnail.URL}">
    29                         <img class="thumbnail" src="{$pwg->derivative_url($derivative_params, $thumbnail.src_image)}" alt="{$thumbnail.TN_ALT}" title="{$thumbnail.TN_TITLE}">
     32                        <img class="thumbnail" {if !$derivative->is_cached()}data-{/if}src="{$derivative->get_url()}" alt="{$thumbnail.TN_ALT}" title="{$thumbnail.TN_TITLE}">
    3033                </a>
    3134                </span>
Note: See TracChangeset for help on using the changeset viewer.