Force Regenerate Thumbnails - Version 2.0.3

Version Description

  • Add debug information on regenerate
  • Fix issue with update "wp_attachment_metadata" and "_wpattached_file" on windows
Download this release

Release Info

Developer Pedro Elsner
Plugin Icon 128x128 Force Regenerate Thumbnails
Version 2.0.3
Comparing to
See all releases

Code changes from version 2.0.2 to 2.0.3

Files changed (2) hide show
  1. force-regenerate-thumbnails.php +24 -3
  2. readme.txt +4 -0
force-regenerate-thumbnails.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Force Regenerate Thumbnails
4
  Plugin URI: http://pedroelsner.com/2012/08/forcando-a-atualizacao-de-thumbnails-no-wordpress
5
  Description: Delete and REALLY force the regenerate thumbnail.
6
- Version: 2.0.2
7
  Author: Pedro Elsner
8
  Author URI: http://www.pedroelsner.com/
9
  */
@@ -462,6 +462,10 @@ class ForceRegenerateThumbnails {
462
 
463
  // Get original image
464
  $image_fullpath = get_attached_file($image->ID);
 
 
 
 
465
 
466
 
467
  // Can't get image path
@@ -470,6 +474,7 @@ class ForceRegenerateThumbnails {
470
  // Try get image path from url
471
  if ((strrpos($image->guid, $upload_dir['baseurl']) !== false)) {
472
  $image_fullpath = realpath($upload_dir['basedir'] . DIRECTORY_SEPARATOR . substr($image->guid, strlen($upload_dir['baseurl']), strlen($image->guid)));
 
473
  if (realpath($image_fullpath) === false) {
474
  throw new Exception(sprintf(__('The originally uploaded image file cannot be found at "%s".', 'force-regenerate-thumbnails'), esc_html((string) $image_fullpath)));
475
  }
@@ -482,14 +487,18 @@ class ForceRegenerateThumbnails {
482
  // Image path incomplete
483
  if ((strrpos($image_fullpath, $upload_dir['basedir']) === false)) {
484
  $image_fullpath = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . $image_fullpath;
 
485
  }
486
 
 
 
487
  // Image don't exists
488
  if (!file_exists($image_fullpath) || realpath($image_fullpath) === false) {
489
 
490
  // Try get image path from url
491
  if ((strrpos($image->guid, $upload_dir['baseurl']) !== false)) {
492
  $image_fullpath = realpath($upload_dir['basedir'] . DIRECTORY_SEPARATOR . substr($image->guid, strlen($upload_dir['baseurl']), strlen($image->guid)));
 
493
  if (realpath($image_fullpath) === false) {
494
  throw new Exception(sprintf(__('The originally uploaded image file cannot be found at "%s".', 'force-regenerate-thumbnails'), esc_html((string) $image_fullpath)));
495
  }
@@ -506,7 +515,7 @@ class ForceRegenerateThumbnails {
506
  *
507
  * @since 2.0.2
508
  */
509
- update_attached_file($image->ID, realpath($image_fullpath));
510
 
511
 
512
  // Results
@@ -609,7 +618,19 @@ class ForceRegenerateThumbnails {
609
  * Display results
610
  */
611
  $message = sprintf(__('<b>&quot;%s&quot; (ID %s)</b>', 'force-regenerate-thumbnails'), esc_html(get_the_title($id)), $image->ID);
612
- $message .= sprintf(__('<br />Original image: %s', 'force-regenerate-thumbnails'), $image_fullpath);
 
 
 
 
 
 
 
 
 
 
 
 
613
  if (count($thumb_deleted) > 0) {
614
  $message .= sprintf(__('<br />Deleted: %s', 'force-regenerate-thumbnails'), implode(', ', $thumb_deleted));
615
  }
3
  Plugin Name: Force Regenerate Thumbnails
4
  Plugin URI: http://pedroelsner.com/2012/08/forcando-a-atualizacao-de-thumbnails-no-wordpress
5
  Description: Delete and REALLY force the regenerate thumbnail.
6
+ Version: 2.0.3
7
  Author: Pedro Elsner
8
  Author URI: http://www.pedroelsner.com/
9
  */
462
 
463
  // Get original image
464
  $image_fullpath = get_attached_file($image->ID);
465
+ $debug_1 = $image_fullpath;
466
+ $debug_2 = '';
467
+ $debug_3 = '';
468
+ $debug_4 = '';
469
 
470
 
471
  // Can't get image path
474
  // Try get image path from url
475
  if ((strrpos($image->guid, $upload_dir['baseurl']) !== false)) {
476
  $image_fullpath = realpath($upload_dir['basedir'] . DIRECTORY_SEPARATOR . substr($image->guid, strlen($upload_dir['baseurl']), strlen($image->guid)));
477
+ $debug_2 = $image_fullpath;
478
  if (realpath($image_fullpath) === false) {
479
  throw new Exception(sprintf(__('The originally uploaded image file cannot be found at &quot;%s&quot;.', 'force-regenerate-thumbnails'), esc_html((string) $image_fullpath)));
480
  }
487
  // Image path incomplete
488
  if ((strrpos($image_fullpath, $upload_dir['basedir']) === false)) {
489
  $image_fullpath = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . $image_fullpath;
490
+ $debug_3 = $image_fullpath;
491
  }
492
 
493
+
494
+
495
  // Image don't exists
496
  if (!file_exists($image_fullpath) || realpath($image_fullpath) === false) {
497
 
498
  // Try get image path from url
499
  if ((strrpos($image->guid, $upload_dir['baseurl']) !== false)) {
500
  $image_fullpath = realpath($upload_dir['basedir'] . DIRECTORY_SEPARATOR . substr($image->guid, strlen($upload_dir['baseurl']), strlen($image->guid)));
501
+ $debug_4 = $image_fullpath;
502
  if (realpath($image_fullpath) === false) {
503
  throw new Exception(sprintf(__('The originally uploaded image file cannot be found at &quot;%s&quot;.', 'force-regenerate-thumbnails'), esc_html((string) $image_fullpath)));
504
  }
515
  *
516
  * @since 2.0.2
517
  */
518
+ update_attached_file($image->ID, $image_fullpath);
519
 
520
 
521
  // Results
618
  * Display results
619
  */
620
  $message = sprintf(__('<b>&quot;%s&quot; (ID %s)</b>', 'force-regenerate-thumbnails'), esc_html(get_the_title($id)), $image->ID);
621
+
622
+
623
+ $message .= "<br /><br />";
624
+ $message .= sprintf(__("<code>BaseDir: %s</code><br />", 'force-regenerate-thumbnails'), $upload_dir['basedir']);
625
+ $message .= sprintf(__("<code>BaseUrl: %s</code><br />", 'force-regenerate-thumbnails'), $upload_dir['baseurl']);
626
+ $message .= sprintf(__("<code>Image: %s</code><br />", 'force-regenerate-thumbnails'), $debug_1);
627
+ if ($debug_2 != '')
628
+ $message .= sprintf(__("<code>Image Debug 2: %s</code><br />", 'force-regenerate-thumbnails'), $debug_2);
629
+ if ($debug_3 != '')
630
+ $message .= sprintf(__("<code>Image Debug 3: %s</code><br />", 'force-regenerate-thumbnails'), $debug_3);
631
+ if ($debug_4 != '')
632
+ $message .= sprintf(__("<code>Image Debug 4: %s</code><br />", 'force-regenerate-thumbnails'), $debug_4);
633
+
634
  if (count($thumb_deleted) > 0) {
635
  $message .= sprintf(__('<br />Deleted: %s', 'force-regenerate-thumbnails'), implode(', ', $thumb_deleted));
636
  }
readme.txt CHANGED
@@ -27,6 +27,10 @@ See the [screenshots tab](http://wordpress.org/extend/plugins/force-regenerate-t
27
 
28
  == ChangeLog ==
29
 
 
 
 
 
30
  = 2.0.2 =
31
  * New style for results (thanks @justonarnar)
32
  * Automatic update "_wp_attachment_metadata" and "_wp_attached_file" (thanks @norecipes)
27
 
28
  == ChangeLog ==
29
 
30
+ = 2.0.3 =
31
+ * Add debug information on regenerate
32
+ * Fix issue with update "_wp_attachment_metadata" and "_wp_attached_file" on windows
33
+
34
  = 2.0.2 =
35
  * New style for results (thanks @justonarnar)
36
  * Automatic update "_wp_attachment_metadata" and "_wp_attached_file" (thanks @norecipes)