| 开发者 |
nasruleam
celsiusanderson |
|---|---|
| 更新时间 | 2026年11月30日 09:52 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPL-2.0-or-later |
| 版权网址: | 版权信息 |
get_server_cpu_load()) with dynamic batch pacing, cooling backoffs, and safe execution.loading="lazy", injects fetchpriority="high" and decoding="async", and outputs high-priority <link rel="preload"> in <head>.wp smrc stats, wp smrc regen, wp smrc prune, and wp smrc redirect.lc-smart-media-redirect-cleaner folder to /wp-content/plugins/.AVIF and WebP solve file compression (bytes per pixel), but thumbnail sizes solve display resolution, mobile GPU memory decoding, and responsive srcset layout. Even an ultra-compressed 24-megapixel AVIF takes 96 MB of RAM for a mobile device to decompress into GPU memory; loading 30 full-res images on a mobile page can cause browser lag or out-of-memory crashes. Resizing to a thumbnail (e.g. 400x300 px) in AVIF reduces file size from ~350 KB down to just ~8 KB (a 99.8% reduction!) while decoding in under 0.5 MB of RAM. LC Smart Media Redirect & Cleaner lets you keep only the 2-3 essential responsive sizes in AVIF/WebP, and dynamically redirects any missing legacy requests on the fly with zero 404s.
When a theme or plugin requests an image size that you deleted or disabled, Smart Size Redirect intercepts the request and dynamically serves the closest available registered size with matching aspect ratio, preventing broken layouts without generating unnecessary files.
ajax_import_config() clamping smrc_max_original_width to a minimum of 1200 (which silently re-enabled master image downscaling when importing presets where auto-downscale was disabled at 0), added explicit return; statements after error responses, and called Smrc_Core::reset_redirect_caches() plus Smrc_Core::reset_folder_scan() on import; updated Admin_Interface::handle_save_settings() to persist smrc_max_original_width, smrc_lcp_preload_enabled, and reset redirect caches on form save; and completed uninstall.php cleanup to remove smrc_bic_migrated plus .smrc_cache/ dotfiles (.htaccess) via DirectoryIterator so @rmdir() leaves zero directory residue.Smrc_CLI_Command::prune() scanning only the first 5,000 files instead of paginating the full uploads tree and synced smrc_bg_scan_results / stats caches after deletion; hardened Smrc_CLI_Command::regen() with --reset, registered size validation, batch-error continuation instead of premature aborts when $processed === 0, and stats invalidation; guarded Smrc_CLI_Command::redirect() against conflicting --enable/--disable flags and flushed redirect caches; preserved original "Download Preset" button labels, enforced 2 MB import file limit, escaped status notices via .text(), synced SMRC_DATA runtime scan/min-width values after settings updates, styled .smrc-setting-save-status, and prevented #smrc-import-file / slider horizontal overflow on mobile.SQL_CALC_FOUND_ROWS and term/meta cache preloading inside Smrc_Core::get_next_batch(); skipped image/svg+xml attachments inside Smrc_Core::process_image() so vector uploads never log bogus wp_get_image_editor() errors; cleaned up adjacent .webp/.avif companion variants via Smrc_Core::delete_adjacent_image_companions() when non-shared thumbnails are replaced or batch-nuked (delete_all_thumbnails_batch() and delete_thumbnail_size_files()); added keyset pagination ($last_id / $known_total) to delete_all_thumbnails_batch() and ajax_delete_all_thumbnails() to eliminate O(N^2) offset scans; and replaced full-table ORDER BY RAND() scans inside ajax_get_image_comparison() with indexed ID-range sampling plus both .webp/.avif and .jpg.webp/.jpg.avif detection.smrc_bg_regen_start()), clamped background batch sizes (1..500), invalidated folder stats caches on foreground/background completion, and applied throttle_delay_ms CPU load pacing across both ajax_run_batch() and smrc_bg_regen_batch(); fixed resume bar width reading pixels instead of percentage (parseFloat(.smrc-progress-text)), escaped modal/banner HTML, synced live error log rows, restored #smrc-bg-regen-cancel icon markup after cancel requests, synced slider width on #smrc-cmp-img-after image load, prevented mobile touchmove scroll hijack during drag, and wrapped #smrc-comparison-modal banners/footers for <= 600px screens.smrc_prune_prepare() into a single RecursiveCallbackFilterIterator pass that prunes .smrc_cache, symlinks, hidden dot-directories, and optimizer backup folders before descent and evaluates orphan keep-dimension rules inline without double-scanning or buffering full path buckets; skipped smrc_build_wp_safe_set() when no matches exist and skipped .smrc_cache/transient state writes during dry-run previews (mode=dry); added smrc_is_path_in_wp_safe_set() to protect active WebP/AVIF companions alongside registered WP images/thumbnails; converted smrc_build_wp_safe_set() and Smrc_Core::delete_thumbnail_size_files() to keyset pagination while cleaning up adjacent WebP/AVIF companions and stale metadata on size deletion; and enabled Folder Analysis Delete All in Admin_Interface::handle_delete_thumbnail_size() for both registered and ghost/legacy thumbnail sizes.smrc_prune_sanitize_token(), stopped redundant large transient writes when .smrc_cache JSON state succeeds, reset folder stats cache when smrc_prune_delete_batch() finishes deletions, added missing return; statements across handle-prune.php / handle-delete.php, removed the unnecessary is_readable() block with clearstatcache() in smrc_delete_file_and_count(), defined missing .smrc-hidden CSS so #smrc_prune_cancel stays hidden when idle, honored mid-scan Cancel clicks before starting batch deletion, escaped dynamic JS error/progress HTML in prune notices, displayed skipped counts and synchronized Folder Analysis size lists after lazyLoadStats() via delegated .smrc-delete-thumbnail-size click handlers, and added mobile wrapping/scroll rules for prune tables and breakdown items.wp_postmeta SQL lookups inside Smrc_Core::get_orphaned_files() (300–600 queries/batch -> 1 bulk query/batch) with Smrc_Core::get_registered_attachment_path_map() and Smrc_Core::is_known_attachment_or_companion(); pruned .smrc_cache, symlinks, and backup folders before directory recursion; scoped orphan file cache keys by subdirectory; and protected active WordPress -scaled unscaled masters (original_image) plus Pro .webp/.avif companions from false-positive orphan classification and deletion.ajax_delete_orphaned_metadata() and ajax_delete_orphaned_files() to purge deleted items from smrc_bg_scan_results (preventing deleted items from reappearing on reload) and reset stats caches; chunked large orphan deletions into 200-item AJAX batches in admin-script.js to avoid PHP max_input_vars truncation; escaped toast showNotification() text and added explicit .smrc-notification, .smrc-orphan-controls, and .smrc-orphan-list styling/scrolling with mobile modal containment; included piu counts in background scan banners; guarded #smrc-clear-bg-scan error states and .smrc-folder-toggle selectors; and added return; after wp_send_json_error() in handle-orphan-bg.php.Smrc_Core::filter_woocommerce_sizes_to_resize() hooked onto woocommerce_image_sizes_to_resize so disabled or Smart-Size-Redirected WooCommerce image sizes never trigger synchronous disk creation or wp_postmeta writes during frontend visitor GET requests (23.55ms / 9 queries / 1 write reduced to 0.69ms / 4 queries / 0 writes).Smrc_Core::scale_original_on_upload(); added get_queried_object_id() fallback in LCP preload/attribute hooks; preserved self-closing <img ... /> syntax in optimize_lcp_content_image(); and centralized Smrc_Core::reset_redirect_caches() across redirect/size mutations.ajax_save_size_override(), cleared stale smrc_size_overrides and pruned option references on custom size edits/deletions, synced UI cards/badges dynamically with escHtml(), wrapped Smart Size Redirect chips and Registered Sizes controls for mobile (<= 600px / <= 480px), and added horizontal scroll containment for #smrc-custom-sizes-table.formatStorageSize(0) returning "0 MB" instead of '0 B' (which prevented lazyLoadStats() from firing on cold transients), added KB and non-finite guards, marked cold states with data-stats-cold="1", removed the unmatched stray CSS brace in admin-style.css, preserved horizontal top-nav labels on <= 960px viewports even when auto-collapsed, synced #smrc-side-toggle aria-expanded, tightened mobile padding at <= 480px, and pointed Quick Setup Step 2 directly to #smart-size-redirect-tab.smrc_list_upload_subpaths() scanning on dashboard render, pruned .smrc_cache/symlinks/backup directories from Smrc_Core::get_video_statistics(), checked accumulator expiry before querying in Smrc_Core::scan_stats_batch() while running the COUNT(*) query once on offset === 0, excluded image/svg+xml from non-SVG metadata/size tallies in smrc_media_analysis(), unified ajax_refresh_stats() authorization, and removed shadowed/incomplete escHtml in admin-script.js.$persist = false mode to Smrc_Core::get_processing_stats() so loading admin.php?page=smrc-dashboard performs 0 option write queries while batch mutations (ajax_run_batch) still persist counters.#smrc_nonce globally in dashboard.php (eliminating duplicate IDs in the Quick Setup step form and fixing silent nonce failure when clicking "Delete All" on thumbnail sizes or folders after Quick Setup completes).#smrc-comparison-modal in admin-style.css, plus decoded plain-text modal titles and structured error extraction in admin-script.js.smrc_regen_acquire_processing_lock(300) to automatically reclaim orphaned smrc_regeneration_processing_lock locks older than 5 minutes after fatal worker timeouts in both smrc_bg_regen_batch() and ajax_run_batch()..smrc_cache/, symlinks, and optimizer backup directories from Smrc_Core::get_orphaned_files(); protected WP -scaled original_image backups inside smrc_build_wp_safe_set(); escaped $wpdb->esc_like() trailing-slash paths in cleanup_database_references(); gated orphan_summary output behind discover_orphans; escaped dynamic JS HTML strings in orphan lists and confirmation modals; guarded # anchor smooth-scroll clicks against jQuery selector syntax errors; and prevented stale sidebar .is-active highlights across Pro tabs.wp_parse_url() paths to (string) in render_lcp_preload_tag() and strip_srcset_originals(), escaped suggestion HTML names in smrc_media_analysis(), and added responsive < 1080px / < 840px / < 600px / < 480px rules for Quick Setup steps, comparison slider modal, and metrics grid.Smrc_Core::get_canonical_target_sizes() and Smrc_Core::find_best_redirect_target(). Reduces redundant option table lookups and aspect-ratio scoring calculations to 0.001ms across high-density image galleries and archive pages.wp_ajax_smrc_*) behind is_admin() || DOING_AJAX, eliminating unnecessary hook table bloat and memory consumption during public visitor GET requests.smrc_bic_migrated), ensuring table updates never repeat after initial migration.maybe_upgrade() out of frontend plugins_loaded so that schema and version upgrade routines execute exclusively during administrative console requests (admin_init) and plugin activation, eliminating redundant write queries and table locks on public visitor page loads..smrc_cache/ review state files (smrc_prune_purge_stale_cache_files()) older than 12 hours upon new review generation, preventing filesystem accumulation from abandoned scans.uninstall.php to clean all lingering cache files and safely remove the .smrc_cache/ uploads directory upon plugin deletion..smrc_cache/) with transient fallback, eliminating MySQL packet exhaustion and timeout bottlenecks when processing 40,000+ files.orphan_summary preview arrays to avoid large JSON transfers during orphan discovery.Plugin URI to https://www.lightandcomposition.com/dev/lc-smart-media-redirect-cleaner/ across plugin headers, Dev Lab catalog, and metadata mappings.lc-smart-media-redirect-cleaner, full text domain unification, unslashed and sanitized nonce verification, and template late-escaping audit.smrc_max_original_width, smrc_lcp_preload_enabled) to uninstall.php and activate() / maybe_upgrade() defaults.sanitize_key() and wp_unslash() sanitization across admin form actions and AJAX request parameters.LC Smart Media Redirect & Cleaner (slug: smart-media-redirect-cleaner) to ensure distinctiveness and eliminate generic/trademark collisions.sanitize_json_payload() sanitization engine to validate, unslash, and sanitize all keys and nested values decoded from configuration imports prior to database persistence and action hook distribution (smrc_import_config_settings).nonce, offset, batch_size, ids, files).celsiusanderson to contributors and verified compatibility with WordPress 7.1.avif_count and avif_size in resetAccum(), preventing NaN live count formatting during active scans.ajax_get_image_comparison() to recognize .avif companion files for native WebP uploads.get_folder_statistics(), get_database_statistics(), and the batched background scan engine (scan_stats_batch()), including AVIF files in total storage calculations.#smrc-bar-avif segment and legend indicator to the Overview dashboard card.wp smrc stats now displays total AVIF file counts and human-readable disk sizes.Smrc_Core::get_server_cpu_load() and Smrc_Core::get_cpu_cores() supporting multi-OS load detection (Linux /proc/loadavg, macOS sysctl, Windows NUMBER_OF_PROCESSORS) to dynamically pace batch operations and prevent server resource exhaustion.ajax_get_image_comparison() with random media sampling and missing disk file candidate fallback.wp_parse_url() in LCP preload tag generator and added decoding="async" to first content image.wp smrc prune WP-CLI command.<link rel="preload" as="image"> with fetchpriority="high" in <head>, strips loading="lazy", and applies decoding="async" to optimize Google PageSpeed LCP score.wp smrc stats, wp smrc regen, wp smrc prune, and wp smrc redirect.smrc_* prefix with automatic zero-data-loss migration on boot (maybe_migrate_legacy_bic_data()).smrc_* keys while seamlessly supporting legacy import formats.smrc_get_registered_sizes() now uses Smrc_Core::get_image_sizes() directly, ensuring all registered theme, WooCommerce, and custom image sizes appear in the Image Sizes tab even when disabled from upload generation.$ignore_custom_mappings parameter to find_best_redirect_target() to compute pure algorithmic defaults independently of active manual overrides, ensuring "Reset Mappings to Auto" always accurately restores true algorithmic matches.OVERRIDE badge indicator on SSR dashboard chips whenever a custom manual destination is active.thumbnail, medium, large, crop settings) and Smart Size Redirect rules (bic_size_redirect with exclusions and custom dynamic mappings).smrc_export_config_payload filter and smrc_import_config_settings action hooks, enabling Pro to serialize and restore complete optimization stacks.smrc-config-YYYY-MM-DD.json).get_size_width_unfiltered() previously checked options-table widths for core sizes 1536x1536 and 2048x2048, where options do not exist. Removed them from core options lookup so they properly resolve from $_wp_additional_image_sizes (1536px and 2048px) and map to large thumbnails instead of falling back to full master photos.delete_all_thumbnails_batch() now enforces realpath, uploads base-prefix boundary matching, and symlink skipping matching the security model of delete_thumbnail_size_files().get_database_statistics, get_folder_statistics, scan_stats_batch) now includes .webp companion file sizes in total_size and computes webp_percentage accurately. Added dynamic #smrc-bar-webp segment and legend to the Storage Breakdown dashboard card.#smrc_prune_run, #smrc_prune_cancel, batch deletion progress chunks, and scan status UI in admin script and stylesheet.class-admin-interface.php from legacy 4.0 to 5.0, matching plugin declarations and runtime requirements.https://www.lightandcomposition.com/.Plugin URI now points to the plugin's Dev Lab page (/dev/smart-media-redirect-cleaner/) instead of the wordpress.org listing.delete_thumbnail_size_files(): $uploads_prefix was undefined inside this function (only set in the sibling delete_all_thumbnails_batch()). Caused the path-traversal guard to always be empty-string truthy → silently skipped every file → "Delete Size" button did nothing. Variable now properly derived from realpath(wp_upload_dir()['basedir']).selected_count < total_reg_count. New logic: step is done if (a) any disabled sizes, (b) any selected sizes (including all), or (c) the option was ever explicitly saved in the DB (get_option sentinel check).selected_sizes < registered count) OR if Uploads creation is disabled (disabled_sizes is non-empty).image-sizes tab ID for seamless jump navigation.flex: 0 0 auto to .smrc-qs-step containers to prevent flex shrinkage and line overlaps across step labels.text-decoration: none !important overrides to eliminate WordPress core .is-done strike-through text styling.bic_* keys remain available only as existing stored-data compatibility identifiers.bic_* settings, metadata, and cron keys belong to LC Smart Media Redirect & Cleaner’s existing data contract and are intentionally not executable class or function names.apply_size_redirect_filter() and find_best_redirect_target()) now explicitly preserves the 'full' image size without intercepting or redirecting to intermediate thumbnails, guaranteeing high-resolution master uploads (art photography, hero images) are never downscaled or stripped from srcset.smrc_get_registered_sizes() now uses Smrc_Core::get_image_sizes() directly, ensuring all registered theme, WooCommerce, and custom image sizes appear in the Image Sizes tab even when disabled from upload generation..m4a/.mp3, Video .webm/.mp4, Originals, Thumbnails) across Storage Overview metrics, live AJAX scan accumulator, bar breakdown chart, and WP-CLI commands..m4a and .mp3) storage tracking across database attachments and deep-dive narration directories.lc-smart-media-redirect-cleaner across all PHP files, templates, and translation calls per WordPress.org Directory slug alignment.sanitize_text_field( wp_unslash( $_POST['nonce'] ) )).esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) )).image_downsize filter when SMRC has nothing to redirect. This keeps CDN/offload/image-optimization integrations compatible instead of overwriting their valid result with false.batch-image-cleaner (formerly reachable only
from the WordPress Tools submenu) into its own top-level admin menu item, redesigned with the
shared sidebar + click-to-show-tabs dashboard used across this plugin suite.