Ignore:
Timestamp:
Jul 24, 2012, 3:38:35 PM (12 years ago)
Author:
plg
Message:

compatibility with Piwigo 2.4

ability to use jpegtran with $confrotate_image_jpegtran = true : lossless photo rotation

File:
1 edited

Legend:

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

    r13524 r16973  
    22/*
    33Plugin Name: Rotate Image
    4 Version: 0.6
     4Version: auto
    55Description: enables to rotate images in batch processing
    66Plugin URI: http://fr.piwigo.org/ext/extension_view.php?eid=578
     
    88if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    99
    10 add_event_handler('loc_begin_element_set_global', 'rotate_image_set_template_data');
    1110add_event_handler('ws_add_methods', 'add_image_rotate_method');
    12 add_event_handler('element_set_global_action', 'rotate_image_element_action', 50, 2);
    13 
    1411function add_image_rotate_method($arr)
    1512{
     
    1714}
    1815
     16add_event_handler('loc_begin_element_set_global', 'rotate_image_set_template_data');
    1917function rotate_image_set_template_data() {
    2018  global $template,$lang;
    2119  load_language('plugin.lang', dirname(__FILE__).'/');
     20
     21  include_once(PHPWG_ROOT_PATH.'admin/include/image.class.php');
     22
    2223  $angles = array (
    23     array('value' => 90, 'name' => l10n('90° left')),
    2424    array('value' => 270, 'name' => l10n('90° right')),
     25    array('value' =>  90, 'name' => l10n('90° left')),
    2526    array('value' => 180, 'name' => l10n('180°'))
    2627  );
     
    4041}
    4142
     43add_event_handler('element_set_global_action', 'rotate_image_element_action', 50, 2);
    4244function rotate_image_element_action($action, $collection) {
    43   global $template;
    4445  if ($action == 'rotateImg') {
    45     //flush thumbnails links by regenerating ramdom ids to uris
    46     $template->delete_compiled_templates();
     46    add_event_handler('get_derivative_url', 'rotate_image_force_refresh', EVENT_HANDLER_PRIORITY_NEUTRAL, 4);
    4747  }
    4848}
    4949
     50function rotate_image_force_refresh($root_url, $params, $src_image, $rel_url)
     51{
     52  global $collection;
     53
     54  if (in_array($src_image->id, $collection))
     55  {
     56    if (strpos($root_url, '?') === false)
     57    {
     58      $root_url.= '?';
     59    }
     60    else
     61    {
     62      $root_url.= '&';
     63    }
     64
     65    $root_url.= 'rand='.md5(uniqid(rand(), true));
     66  }
     67
     68  return $root_url;
     69}
    5070?>
Note: See TracChangeset for help on using the changeset viewer.