Ignore:
Timestamp:
Jan 23, 2015, 7:56:01 PM (9 years ago)
Author:
SergeD
Message:

version 1.0.15 - please refer to changelog for more details

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/GDThumb/main.inc.php

    r30890 r30901  
    22/*
    33Plugin Name: gdThumb
    4 Version: 1.0.14
    5 Description: Display thumbnails as patchwork
     4Version: 1.0.15
     5Description: Apply Masonry style to album or image thumbs
    66Plugin URI: http://piwigo.org/ext/extension_view.php?eid=771
    77Author: Serge Dosyukov
     
    1919// | Plugin constants                                               |
    2020// +-----------------------------------------------------------------------+
    21 define('GDTHUMB_VERSION', '1.0.14');
     21define('GDTHUMB_VERSION', '1.0.15');
    2222define('GDTHUMB_ID',      basename(dirname(__FILE__)));
    2323define('GDTHEME_PATH' ,   PHPWG_THEMES_PATH . 'greydragon/');
     
    5959function GDThumb_index() {
    6060  global $template;
    61  
     61
     62  $template->smarty->registerPlugin("function", "media_type", "GDThumb_media_type");
    6263  $template->set_prefilter('index', 'GDThumb_prefilter');
    6364
    6465  add_event_handler('loc_end_index_thumbnails', 'GDThumb_process_thumb', 50, 2);
     66}
     67                                                 
     68function GDThumb_endsWith($needles, $haystack) {
     69  if(empty($needles) || empty($haystack)):
     70    return false;
     71  else:
     72    $arr_needles = explode(',', $needles);
     73   
     74    foreach ((array) $arr_needles as $needle) {
     75      if ((string) $needle === substr($haystack, -strlen($needle))) return true;
     76    }
     77    return false;
     78  endif;
     79}
     80
     81function GDThumb_media_type($params, $smarty) {
     82  if(empty($params["file"]))
     83    return "image";
     84
     85  $file = $params["file"];
     86  if (GDThumb_endsWith("webm,webmv,ogv,m4v,flv,mp4", $file))
     87    return "video";
     88  if (GDThumb_endsWith("mp3,ogg,oga,m4a,webma,fla,wav", $file))
     89    return "music";
     90  if (GDThumb_endsWith("pdf", $file))
     91    return "pdf";
     92  if (GDThumb_endsWith("doc,docx,odt", $file))
     93    return "doc";
     94  if (GDThumb_endsWith("xls,xlsx,ods", $file))
     95    return "xls";
     96  if (GDThumb_endsWith("ppt,pptx,odp", $file))
     97    return "ppt";
     98
     99  return "image";
    65100}
    66101
Note: See TracChangeset for help on using the changeset viewer.