Ignore:
Timestamp:
Jul 10, 2011, 4:36:46 PM (13 years ago)
Author:
flop25
Message:

omg i did it ! dynamic generation of thumbnails.tpl
admin page for width and this dynamic generation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/stripped_black_bloc/themeconf.inc.php

    r11697 r11699  
    2323load_language('theme.lang', PHPWG_THEMES_PATH.'stripped_black_bloc/');
    2424
     25// Need upgrade?
    2526
     27global $conf;
     28
     29if (!isset($conf['stripped_black_bloc']))
     30  include(PHPWG_THEMES_PATH.'stripped_black_bloc/admin/upgrade.inc.php');
     31
     32add_event_handler('loc_begin_page_header', 'set_config_values_stripped_black_bloc');
     33
     34function set_config_values_stripped_black_bloc()
     35{
     36        global $conf, $template;
     37        $config = unserialize( $conf['stripped_black_bloc'] );
     38        $template->assign( 'stripped_black_bloc', $config );
     39}
     40
     41/// EVENT
    2642add_event_handler('loc_end_index_category_thumbnails', 'MY');
    2743add_event_handler('loc_end_index_thumbnails', 'MY');
    2844function MY($tpl_thumbnails_var)
    2945{
    30     global $template;
     46    global $template, $conf;
     47                $config = unserialize( $conf['stripped_black_bloc'] );
    3148                $new_tplvar=array();
    3249                foreach ($tpl_thumbnails_var as $tplvar)
     
    3552                        $tplvar['TN_WIDTH']=$width;
    3653                        $tplvar['TN_HEIGHT']=$height;
     54                        if (isset($config['thumbnail']))
     55                        {
     56                                switch ($config['thumbnail'])
     57                                {
     58                                        case 'generated':
     59                                                $tplvar['TN_SRC']=PHPWG_THEMES_PATH."stripped_black_bloc/library/timthumb.php?src=".$tplvar['TN_SRC']."&w=".$config['thumbnail_width'];
     60                                                $tplvar['TN_HEIGHT']=floor($tplvar['TN_HEIGHT']*($config['thumbnail_width']/$tplvar['TN_WIDTH']));
     61                                                $tplvar['TN_WIDTH']=$config['thumbnail_width'];
     62                                        break;
     63                                        case 'auto':
     64                                                if($tplvar['TN_WIDTH']<=$config['thumbnail_width'])
     65                                                {
     66                                                        $tplvar['TN_SRC']=PHPWG_THEMES_PATH."stripped_black_bloc/library/timthumb.php?src=".$tplvar['TN_SRC']."&w=".$config['thumbnail_width'];
     67                                                        $tplvar['TN_HEIGHT']=floor($tplvar['TN_HEIGHT']*($config['thumbnail_width']/$tplvar['TN_WIDTH']));
     68                                                        $tplvar['TN_WIDTH']=$config['thumbnail_width'];
     69                                                }
     70                                        break;
     71                                        case 'piwigo':break;
     72                                }
     73                        }
    3774                        $new_tplvar[]=$tplvar;
    3875                }
Note: See TracChangeset for help on using the changeset viewer.