Changeset 1481443
- Timestamp:
- 08/23/2016 10:18:22 AM (10 years ago)
- Location:
- imagecare/trunk
- Files:
-
- 6 edited
-
imagecare.zip (modified) (previous)
-
inc-func-cleanregen.php (modified) (4 diffs)
-
inc-func-maxres.php (modified) (2 diffs)
-
inc-func-regensizes.php (modified) (3 diffs)
-
inc-iface-regensizes.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
imagecare/trunk/inc-func-cleanregen.php
r1448419 r1481443 9 9 $pid = !empty($_POST['id']) ? (int) $_REQUEST['id'] : 0; 10 10 11 $ info = get_post_meta($pid, '_wp_attachment_metadata', true);11 $org = $info = get_post_meta($pid, '_wp_attachment_metadata', true); 12 12 if($info) { 13 13 $path = $this->path.dirname($info['file']).'/'; … … 15 15 $fname = basename($file); 16 16 $finfo = pathinfo($file); 17 $files = glob($path.$finfo['filename'].'-*.'.$finfo['extension']); // TODO add a safe filter17 $files = glob($path.$finfo['filename'].'-*.'.$finfo['extension']); // TODO add a safer filter 18 18 $ok = true; 19 19 $amt1 = count($files); … … 30 30 $error = sprintf( __('Unable to regenerate metadata (ID %1$s «Unknown reason»)', 'imagecare'), $pid); 31 31 } else { 32 if(wp_update_attachment_metadata( $pid, $metadata )) { 32 if($org===$metadata) { 33 $success = sprintf( __( '"%1$s" (ID %2$s) already had the right size.', 'imagecare' ), $fname, $pid ); 34 } elseif(wp_update_attachment_metadata( $pid, $metadata )) { 33 35 $files = glob($path.$finfo['filename'].'-*.'.$finfo['extension']); 34 36 $amt2 = count($files); … … 39 41 $success .= sprintf( __( '"%1$s" (ID %2$s) was successfully regenerated from %3$s files (%4$s Kb) to %5$s files (%6$s Kb) saving %7$s Kb.', 'imagecare' ), $fname, $pid, $amt1, intval($size1/1024), $amt2, intval($size2/1024), $saved ); 40 42 } else { 41 $error = sprintf( __('File "%1$s" (ID %2$s) failed when updating the database', 'imagecare'), $ img, $pid);43 $error = sprintf( __('File "%1$s" (ID %2$s) failed when updating the database', 'imagecare'), $fname, $pid); 42 44 } 43 45 } -
imagecare/trunk/inc-func-maxres.php
r1448419 r1481443 16 16 if($info) { 17 17 $file = $this->path.$info['file']; 18 $fname = basename($file); 19 $finfo = pathinfo($file); 18 20 $img_o = imagecreatefromjpeg($file); 19 21 $img_w = imagesx($img_o); … … 47 49 $saved = intval(($img_s-$new_s)/1024); 48 50 if(update_post_meta($pid, '_wp_attachment_metadata', $info)) { 49 $success = sprintf( __( '"%1$s" (ID %2$s) was successfully from %3$s to %4$s saving %5$s.', 'imagecare' ), $f ile, $pid, $res1, $res2, $saved );51 $success = sprintf( __( '"%1$s" (ID %2$s) was successfully from %3$s to %4$s saving %5$s.', 'imagecare' ), $fname, $pid, $res1, $res2, $saved ); 50 52 } else { 51 $error = sprintf( __('File "%1$s" (ID %2$s) failed when updating the database', 'imagecare'), $f ile, $pid);53 $error = sprintf( __('File "%1$s" (ID %2$s) failed when updating the database', 'imagecare'), $fname, $pid); 52 54 } 53 55 } else { 54 $error = sprintf( __('File "%1$s" (ID %2$s) failed when saving the file', 'imagecare'), $f ile, $pid);56 $error = sprintf( __('File "%1$s" (ID %2$s) failed when saving the file', 'imagecare'), $fname, $pid); 55 57 } 56 58 } else { 57 $error = sprintf( __('File "%1$s" (ID %2$s) failed to resample', 'imagecare'), $f ile, $pid);59 $error = sprintf( __('File "%1$s" (ID %2$s) failed to resample', 'imagecare'), $fname, $pid); 58 60 } 59 61 } else { 60 $success = sprintf( __( '"%1$s" (ID %2$s) already had the right size.', 'imagecare' ), $f ile, $pid );62 $success = sprintf( __( '"%1$s" (ID %2$s) already had the right size.', 'imagecare' ), $fname, $pid ); 61 63 } 62 64 } else { -
imagecare/trunk/inc-func-regensizes.php
r1448419 r1481443 10 10 $sizes = !empty($_POST['sizes']) ? explode(chr(44), $_REQUEST['sizes']) : 'x'; 11 11 12 $ info = get_post_meta($pid, '_wp_attachment_metadata', true);12 $org = $info = get_post_meta($pid, '_wp_attachment_metadata', true); 13 13 if($info) { 14 14 $file = $this->path.$info['file']; 15 $fname = basename($file); 16 $finfo = pathinfo($file); 15 17 $zizes = $this->get_image_sizes(); 16 18 if($sizes=='x') { … … 23 25 } 24 26 if(!empty($arr)) { 27 foreach($arr as $name=>$values) { 28 $size1 += filesize($finfo['dirname'].'/'.$info['sizes'][$name]['file']); 29 } 30 $amt = count($arr); 25 31 $editor = wp_get_image_editor($file); 26 32 if(!is_wp_error($editor)) { 27 $info['sizes'] = $editor->multi_resize($arr); 28 if(wp_update_attachment_metadata( $pid, $info )) { 29 $success .= sprintf( __( '"%1$s" (ID %2$s) was successfully regenerated from %3$s files (%4$s Kb) to %5$s files (%6$s Kb) saving %7$s Kb.', 'imagecare' ), $fname, $pid, $amt1, intval($size1/1024), $amt2, intval($size2/1024), $saved ); 33 $temp = $editor->multi_resize($arr); 34 foreach($arr as $name=>$values) { 35 $info['sizes'][$name] = $temp[$name]; 36 $size2 += filesize($finfo['dirname'].'/'.$info['sizes'][$name]['file']); 37 } 38 $saved = intval(($size1-$size2)/1024); 39 if($org===$info) { 40 $success = sprintf( __( '"%1$s" (ID %2$s) already had the right size.', 'imagecare' ), $fname, $pid ); 41 } elseif(wp_update_attachment_metadata( $pid, $info )) { 42 $success .= sprintf( __( '"%1$s" (ID %2$s) was successfully regenerated %3$s files from %4$s Kb to %5$s Kb saving %6$s Kb.', 'imagecare' ), $fname, $pid, $amt, intval($size1/1024), intval($size2/1024), $saved ); 30 43 } else { 31 $error = sprintf( __('File "%1$s" (ID %2$s) failed when updating the database', 'imagecare'), $ img, $pid);44 $error = sprintf( __('File "%1$s" (ID %2$s) failed when updating the database', 'imagecare'), $fname, $pid); 32 45 } 33 46 } else { 34 $error = sprintf( __('File "%1$s" (ID %2$s) failed when initializing the editor', 'imagecare'), $ img, $pid);47 $error = sprintf( __('File "%1$s" (ID %2$s) failed when initializing the editor', 'imagecare'), $fname, $pid); 35 48 } 36 49 } else { … … 41 54 } 42 55 43 // sleep( 10);56 // sleep(5); 44 57 45 58 die(json_encode(array( -
imagecare/trunk/inc-iface-regensizes.php
r1448419 r1481443 19 19 <td> 20 20 <input type="checkbox" name="dtop" value="x" checked /> All <br/> 21 <div style="column-count: 4"><?php foreach($sizes as $name=>$size) { ?>22 <input type="checkbox" name="dtop[]" value="<?php echo $name ?>" /> <?php echo $name ?><br/>21 <div style="column-count: 3"><?php foreach($sizes as $name=>$size) { ?> 22 <input type="checkbox" name="dtop[]" value="<?php echo $name ?>" /> <?php echo $name.' ('.$size['width'].'x'.$size['height'].')' ?><br/> 23 23 <?php } ?></div> 24 24 </td> … … 141 141 } 142 142 if(rt_images.length && rt_alive) { 143 //do_it(rt_images.shift());143 do_it(rt_images.shift()); 144 144 } else { 145 145 imagecareFinishUp(); … … 149 149 imagecareUpdateStatus(id, false, response); 150 150 if(rt_images.length && rt_alive) { 151 //do_it(rt_images.shift());151 do_it(rt_images.shift()); 152 152 } else { 153 153 imagecareFinishUp(); -
imagecare/trunk/readme.txt
r1448473 r1481443 16 16 17 17 This plugin let the user to scale all the original images because most user upload images from their cameras with a pointless resolution like 4096x3072 that weight 5Mb and the theme doesn´t use more than -let´s say- 1024px that could weigth 100 Kb in the worst case. 18 19 This plugin let the user to sanitize the filenames removing non-ASCII characters. 18 20 19 21 This plugin also let the user backup images based on year-month. … … 47 49 * First usable version 48 50 51 = 1.5 = 52 * Added the filename sanitization. 53 49 54 == Upgrade Notice == 50 55 51 No previouse versions.56 Added the filename sanitization.
Note: See TracChangeset
for help on using the changeset viewer.