Advertisement
Local_Ghost

Fix unicode file name - Hebrew

Jan 12th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.39 KB | None | 0 0
  1. <?php
  2.  
  3.     $images = glob('wp-content/uploads/*/*/*.jpg');
  4.     $images += glob('wp-content/uploads/*/*/*.png');
  5.    
  6.     foreach( $images as $img ){
  7.         $uncodedImg = urldecode( urldecode( $img ) );
  8.         if( $uncodedImg != $img ){
  9.             if( rename( $img, $uncodedImg ) ){
  10.                 echo 'Image saved: ' . $uncodedImg .'<br/>';
  11.             } else {
  12.                 echo 'Can\'t save image: ' . $uncodedImg .'<br/>';
  13.             }
  14.         }
  15.     }
  16.  
  17. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement