This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function fp_scan_all_nonoptimized_images() | |
| { | |
| $upload_dir = wp_upload_dir(); | |
| $uploads_path = $upload_dir['basedir']; | |
| $uploads_url = $upload_dir['baseurl']; | |
| $optimized_path = WP_CONTENT_DIR . '/flying-press-images'; | |
| $batch = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Get non-optimised image list in batch with generator | |
| function fp_scan_all_images() | |
| { | |
| $upload_dir = wp_upload_dir(); | |
| $uploads_path = $upload_dir['basedir']; | |
| $uploads_url = $upload_dir['baseurl']; | |
| $optimized_path = WP_CONTENT_DIR . '/flying-press-images'; | |
| $batch = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Get difference of two folders and get non-optimised images | |
| function fp_scan_all_images() | |
| { | |
| $upload_dir = wp_upload_dir(); | |
| $uploads_path = $upload_dir['basedir']; | |
| $uploads_url = $upload_dir['baseurl']; | |
| $optimized_path = WP_CONTENT_DIR . '/flying-press-images'; | |
| // Step 1: Build lookup for optimized files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function fp_scan_images_generator() | |
| { | |
| try { | |
| $upload_dir = wp_upload_dir(); | |
| $directory = $upload_dir['basedir']; | |
| // Recursive scan with FileSystemIterator | |
| $iterator = new RecursiveIteratorIterator( | |
| new RecursiveDirectoryIterator($directory, FilesystemIterator::SKIP_DOTS) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Log files in oneshot - NO generator | |
| function fp_scan_images_oneshot($only_non_optimized = false) | |
| { | |
| $base_directory = wp_upload_dir(); | |
| $directory = $base_directory['basedir']; | |
| $optimized_directory = WP_CONTENT_DIR . '/flying-press-images'; | |
| // Recursive scan with FileSystemIterator | |
| $iterator = new RecursiveIteratorIterator( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Log scanned image links to debug.log. | |
| * | |
| * Make sure to enable WP_DEBUG_LOG from wp-config.php to use this command. | |
| */ | |
| function process_image_batch_new($batch_size = 500, $reset = false) | |
| { | |
| $upload_dir = wp_get_upload_dir(); | |
| $batch = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Scan images in batch | |
| function fp_image_scan_batch($batch_size = 500, $reset = false) | |
| { | |
| $upload_dir = wp_get_upload_dir(); | |
| $batch = []; | |
| $log_file = trailingslashit(WP_CONTENT_DIR) . 'fp-image-scan.log'; | |
| // Reset log file on first batch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Batch Process | |
| function process_image_batch($batch_size = 100, $reset = false) | |
| { | |
| $directory = wp_get_upload_dir()['basedir']; | |
| $json_file = trailingslashit(WP_CONTENT_DIR) . 'image.json'; | |
| // First batch → reset file | |
| if ($reset || !file_exists($json_file)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Scan images from uploads folder | |
| function fp_scan_images($offset = 0, $batch_size = 500) | |
| { | |
| try { | |
| $images = []; | |
| $upload_dir = wp_upload_dir(); | |
| $directory = $upload_dir['basedir']; | |
| // Recursive scan with FileSystemIterator |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Scan images from uoloads folder including sub-folders. | |
| function fp_scan_images() { | |
| try { | |
| $images = []; | |
| $upload_dir = wp_upload_dir(); | |
| $directory = $upload_dir['basedir']; | |
| // Recursive scan with FileSystemIterator |
NewerOlder