/[drupal]/contributions/modules/imagecache_actions/imagecache-preview.patch
ViewVC logotype

Contents of /contributions/modules/imagecache_actions/imagecache-preview.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Wed May 28 11:45:08 2008 UTC (18 months ago) by dman
Branch: MAIN
CVS Tags: DRUPAL-5--3-1, DRUPAL-5--2-2, DRUPAL-5--2-3, DRUPAL-5--2-1, DRUPAL-6--1-4, DRUPAL-6--1-5, DRUPAL-6--1-6, DRUPAL-6--1-0, DRUPAL-6--1-1, DRUPAL-6--1-2, DRUPAL-5--2-0, DRUPAL-5--1-0, HEAD
Branch point for: DRUPAL-5--3, DRUPAL-5--2, DRUPAL-6--1
File MIME type: text/x-patch
First commit of the imageapi extensions as per:
http://drupal.org/node/184816
1 Index: imagecache/imagecache.module
2 ===================================================================
3 RCS file: /cvs/drupal-contrib/contributions/modules/imagecache/imagecache.module,v
4 retrieving revision 1.68.2.3
5 diff -u -p -r1.68.2.3 imagecache.module
6 --- imagecache/imagecache.module 11 May 2008 23:58:47 -0000 1.68.2.3
7 +++ imagecache/imagecache.module 28 May 2008 11:42:22 -0000
8 @@ -474,6 +474,8 @@ function imagecache_build_derivative($ac
9 return false;
10 }
11
12 + imagesavealpha($image->res, TRUE);
13 +
14 foreach ($actions as $action) {
15 if (!empty($action['data'])) {
16 // QuickSketch, why do these run first/twice? - dopry.
17 @@ -670,7 +672,9 @@ function _imagecache_keyword_filter($val
18 * A filepath relative to file_directory_path.
19 */
20 function _imagecache_recursive_delete($dir) {
21 + if(!is_dir($dir)) return;
22 $d = dir($dir);
23 + if(!$d) return;
24 while (($entry = $d->read()) !== false) {
25 if ($entry == '.' || $entry == '..') continue;
26 $path = $dir .'/'. $entry;
27 Index: imagecache/imagecache_actions.inc
28 ===================================================================
29 RCS file: /cvs/drupal-contrib/contributions/modules/imagecache/imagecache_actions.inc,v
30 retrieving revision 1.12
31 diff -u -p -r1.12 imagecache_actions.inc
32 --- imagecache/imagecache_actions.inc 24 Apr 2008 05:27:45 -0000 1.12
33 +++ imagecache/imagecache_actions.inc 28 May 2008 11:42:22 -0000
34 @@ -150,6 +150,10 @@ function theme_imagecache_crop($element)
35 }
36
37 function imagecache_crop_image(&$image, $data) {
38 + // Allow for cropping in one dimension only;
39 + if(! $data['width']) {$data['width'] = $image->info['width'];}
40 + if(! $data['height']) {$data['height'] = $image->info['height'];}
41 +
42 if (!imageapi_image_crop($image, $data['xoffset'], $data['yoffset'], $data['width'], $data['height'])) {
43 watchdog('imagecache', t('imagecache_crop failed. image: %image, data: %data.', array('%path' => $image, '%data' => print_r($data, true))), WATCHDOG_ERROR);
44 return false;
45 @@ -216,10 +220,11 @@ function imagecache_rotate_image(&$image
46 // Set sane default values.
47 $data['degrees'] = $data['degrees'] ? $data['degrees'] : 0;
48 $data['random'] = $data['random'] ? $data['random'] : false;
49 - $data['bgcolor'] = $data['bgcolor'] ? $data['bgcolor'] : '#FFFFFF';
50 + $data['bgcolor'] = $data['bgcolor'] ? $data['bgcolor'] : -1; // Transparent
51 + #$data['bgcolor'] = $data['bgcolor'] ? $data['bgcolor'] : '#FFFFFF';
52
53 // Manipulate the if we need to randomize, and convert to proper colors.
54 - $data['bgcolor'] = '0x'. str_replace('#', '', $data['bgcolor']);
55 + // $data['bgcolor'] = '0x'. str_replace('#', '', $data['bgcolor']);
56
57 if (!empty($data['random'])) {
58 $degrees = abs((float)$data['degrees']);
59 @@ -230,5 +235,10 @@ function imagecache_rotate_image(&$image
60 watchdog('imagecache', t('imagecache_rotate_image failed. image: %image, data: %data.', array('%path' => $image, '%data' => print_r($data, true))), WATCHDOG_ERROR);
61 return false;
62 }
63 + // Rotation is likely to change the actual image dimensions. Better make a note of that before the next change
64 + $image->info['width'] = imagesx($image->res);
65 + $image->info['height'] = imagesy($image->res);
66 +
67 +
68 return true;
69 }
70 Index: imagecache/imagecache_ui.module
71 ===================================================================
72 RCS file: /cvs/drupal-contrib/contributions/modules/imagecache/imagecache_ui.module,v
73 retrieving revision 1.11
74 diff -u -p -r1.11 imagecache_ui.module
75 --- imagecache/imagecache_ui.module 24 Apr 2008 05:27:45 -0000 1.11
76 +++ imagecache/imagecache_ui.module 28 May 2008 11:42:22 -0000
77 @@ -121,9 +121,40 @@ function imagecache_ui_presets() {
78 $rows[] = $row;
79 }
80 $output = theme('table', $header, $rows);
81 +
82 + $output .= drupal_get_form(imagecache_settings);
83 +
84 + if(! is_writable( file_create_path('imagecache') )) {
85 + drupal_set_message(t('Warning: The configured imagecache directory [%imagecachedir] cannot be written to by %whoami. You should check permissions on the server', array('%imagecachedir' => file_create_path('imagecache'), '%whoami' => `whoami`)), 'error');
86 + }
87 +
88 return $output;
89 }
90
91 +function imagecache_settings(){
92 + $preview = variable_get('imagecache_preview_image', 'misc/druplicon.png');
93 + $preview_source = file_create_path() .'/'. $preview;
94 + if (! file_exists($preview_source)) {
95 + file_copy($preview, basename($preview_source));
96 + }
97 + $preview_source = file_create_path() .'/'. basename($preview);
98 +
99 + $form = array(
100 + '#type' => 'form',
101 + 'imagecache_preview_image' => array(
102 + '#type' => 'textfield',
103 + '#title' => t('Sample image to use in previews'),
104 + '#default_value' => variable_get('imagecache_preview_image', 'misc/druplicon.png'),
105 + '#description' => t('May be relative to the files directory or the Drupal root'),
106 + ),
107 + 'preview_image' => array(
108 + '#type' => 'markup',
109 + '#value' => theme('image', $preview_source),
110 + )
111 + );
112 + return system_settings_form($form);
113 +}
114 +
115 function imagecache_ui_preset_add_form($presetid = 0) {
116 $form = array();
117 $form['presetname'] = array(
118 @@ -352,6 +383,24 @@ function imagecache_ui_preset_form($pres
119 '#type' => 'submit',
120 '#value' => t('Update Preset'),
121 );
122 +
123 + ///////
124 + // preview
125 + $preview_original = variable_get('imagecache_preview_image', 'misc/druplicon.png');
126 + $preview_source = file_create_path() .'/'. basename($preview_original);
127 + if (! file_exists($preview_source)) {
128 + file_copy($preview_original, $preview_source);
129 + }
130 + $preview_source = file_create_path() .'/'. basename($preview_original);
131 +
132 + imagecache_image_flush($preview_source);
133 + $imagecache_path = imagecache_create_url($preset['presetname'], $preview_source) . '?random='. rand(0,10000);
134 + $form['preview'] = array(
135 + '#type' => 'markup',
136 + '#value' => "<img src='$imagecache_path' /><a href='$imagecache_path' >$imagecache_path</a>",
137 + );
138 + ///////
139 +
140 return $form;
141 }
142

  ViewVC Help
Powered by ViewVC 1.1.2