source: extensions/square_thumbnails/thumbnail.php @ 6299

Last change on this file since 6299 was 5962, checked in by patdenice, 14 years ago

Square option is available for thumbnail creation page and upload form.

File size: 1.4 KB
Line 
1<?php
2
3if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
4
5global $template;
6
7load_language('plugin.lang', SQUARE_THUMB_PATH);
8
9// Add handler for square resize
10if (isset($_POST['square']))
11{
12  include(SQUARE_THUMB_PATH.'functions.inc.php');
13}
14
15// Add prefilter
16$template->set_prefilter('thumbnail', 'add_square_option');
17
18function add_square_option($content, $smarty)
19{
20  $search = '<li>
21        <span class="property">
22          <label for="width">{\'maximum width\'|@translate}</label>';
23
24  $replacement = '
25{html_head}
26{literal}
27<script type="text/javascript">
28jQuery().ready(function(){
29  jQuery(":text").keyup(function(){
30    if(jQuery("#square").attr("checked")){
31      if (this.id == "width"){
32        jQuery("#height").attr("value", this.value);
33      }else{
34        jQuery("#width").attr("value", this.value);
35      }
36    }
37  });
38  jQuery("#square").click(function(){
39    if (this.checked)
40      jQuery("#height").attr("value", jQuery("#width").attr("value"));
41  });
42});
43</script>
44{/literal}
45{/html_head}
46
47      <li>
48        <span class="property">{\'Square Thumbnails\'|@translate}</span>
49             <label><input type="checkbox" name="square" id="square" {if $params.SQUARE}checked="checked"{/if}></label>
50      </li>
51
52      <li>
53        <span class="property">
54          <label for="width">{\'maximum width\'|@translate}</label>';
55
56  return str_replace($search, $replacement, $content);
57}
58
59?>
Note: See TracBrowser for help on using the repository browser.