source: extensions/derivatives/main.inc.php @ 13065

Last change on this file since 13065 was 12775, checked in by rvelices, 13 years ago

derivatives - can display several sizes on picture page

File size: 1.8 KB
Line 
1<?php /*
2Plugin Name: Dynamic images
3Version: 0
4*/
5
6global $conf;
7// 0-'auto', 1-'derivative' 2-'script'
8$conf['derivative_url_style']=0;
9
10defined('PWG_DERIVATIVE_DIR') or define('PWG_DERIVATIVE_DIR', PWG_LOCAL_DIR.'i/');
11
12include_once( dirname(__FILE__) .'/include/derivative_params.inc.php');
13include_once( dirname(__FILE__) .'/include/derivative_std_params.inc.php');
14include_once( dirname(__FILE__) .'/include/derivative.inc.php');
15
16ImageStdParams::load_from_db();
17
18add_event_handler('get_thumbnail_url', 'dyn_thumb_url', 60, 2);
19
20function dyn_thumb_url($url, $infos)
21{
22  $url2 = DerivativeImage::thumb_url($infos);
23  return $url2;
24}
25
26
27add_event_handler(
28  'render_element_content',
29  'dyn_render_picture_content',
30  EVENT_HANDLER_PRIORITY_NEUTRAL-1,
31  2
32  );
33
34function dyn_render_picture_content($content, $element_info)
35{
36  if ( !empty($content) )
37  {// someone hooked us - so we skip;
38    return $content;
39  }
40
41  $all_derivatives = DerivativeImage::get_all($element_info);
42  //var_export($all_derivatives);
43  $selected_derivative = $all_derivatives[IMG_LARGE];
44
45  $available_derivatives = array();
46  $added = array();
47  foreach($all_derivatives as $type => $derivative)
48  {
49    $url = $derivative->get_url();
50    if (isset($added[$url]))
51      continue;
52    $added[$url] = 1;
53    $available_derivatives[] = $type;
54  }
55
56
57  global $user, $page, $template;
58
59  $template->set_filenames(
60    array('default_content'=> dirname(__FILE__).'/picture_content.tpl')
61    );
62
63  $template->append('current', array(
64      'all_derivatives' => $all_derivatives,
65      'selected_derivative' => $selected_derivative,
66      'available_derivative_types' => $available_derivatives,
67    ), true);
68
69  $template->assign( array(
70    'ALT_IMG' => $element_info['file'] ));
71
72  return $template->parse( 'default_content', true);;
73}
74?>
Note: See TracBrowser for help on using the repository browser.