easy_svg_pro_import_max_entries
Set how many SVG files Easy SVG Pro reads out of one ZIP. Applies to set import, pack upload, Font Awesome, presets and wp easy-svg pack import.
Filter · Easy SVG Pro · Status: Stable
When someone imports a ZIP, Easy SVG Pro reads at most 2000 icons out of it. This filter changes that number. It protects the server from an archive with tens of thousands of tiny files, and lets a site with a really large icon set raise the limit on purpose.
Usage
apply_filters( 'easy_svg_pro_import_max_entries', int $max )
Applied in includes/editor/set-import.php, inside zip_entries_from_path(). The result is cast to an integer.
When to use it
- You import a set with more than 2000 icons in one archive and the import stops short.
- You want a tighter limit on a small shared host, so nobody can tie up a worker with a giant archive.
- You run automated imports (
wp easy-svg pack import) and want a limit that matches what your packs really hold.
Do not use it when:
- The archive is big in bytes rather than in files. That is
easy_svg_pro_import_max_total_bytes. - You import an SVG icon font, not a ZIP. That is
easy_svg_pro_import_font_max_bytes. - One single SVG inside the ZIP is too large. Each entry is held to the free plugin's size limit,
easy_svg_max_bytes.
Parameters
How many entries are read out of one archive. Only entries that are kept count: .svg files and manifest.json. Folders, images, text files and anything else are skipped and do not use up the limit.
Return value
The entry limit. The value is not clamped, so 0 or a negative number means nothing is read and every import answers "held no icon this site could accept".
Default
2000.
Examples
Allow larger sets
/**
* Our icon library ships 3500 icons in one pack.
*/
function acme_import_max_entries( $max ) {
return max( $max, 4000 );
}
add_filter( 'easy_svg_pro_import_max_entries', 'acme_import_max_entries' );
max() keeps a higher limit that another plugin may have set.
Raise the limit only for WP-CLI
/**
* The browser keeps the default. Deploy scripts may read more.
*/
function acme_import_max_entries_cli( $max ) {
if ( defined( 'WP_CLI' ) && WP_CLI ) {
return 10000;
}
return $max;
}
add_filter( 'easy_svg_pro_import_max_entries', 'acme_import_max_entries_cli' );
When you raise the number of entries, raise easy_svg_pro_import_max_total_bytes as well, or the byte limit stops the import first.
A tighter limit on a small host, never zero
function acme_import_max_entries_small( $max ) {
return max( 1, min( (int) $max, 500 ) );
}
add_filter( 'easy_svg_pro_import_max_entries', 'acme_import_max_entries_small' );
How it works
Every import of a ZIP goes through one reader, so one rule applies everywhere:
| Path | Where |
|---|---|
| Set import | POST /easy-svg-pro/v1/sets/{id}/import with a .zip |
| Pack upload | Icons → Packs, POST /easy-svg-pro/v1/packs/import |
| Font Awesome download | Icons → Packs with the Font Awesome import feature on |
| Preset install | POST /easy-svg-pro/v1/presets/install |
| Command line | wp easy-svg pack import |
For each entry, in archive order, the reader:
- stops when the number of kept entries has reached your limit,
- skips a name with
..or a leading/, - skips anything that is not
manifest.jsonor a.svgfile, - skips an entry larger than its own cap:
easy_svg_max_bytes()for an SVG (2 MB when the free plugin is missing), 1 MB for the manifest. The size is checked as declared and again after reading, - adds the bytes to a running total and stops when that passes the total byte limit,
- keeps the entry.
Nothing is written to disk. After reading, every SVG goes through the site sanitizer and hardener before it is stored.
Pitfalls
- Entries past the limit are silent. They are never read, so they do not show up as refused either. An import of 2500 files reports 2000 icons and no warning. Count what you expect.
- Archive order decides. Which 2000 files make it depends on the order inside the ZIP, not on the manifest.
- Zero means nothing. Returning
0,nullorfalsestops every ZIP import on the site. - Memory grows with it. Every entry is held in memory, then again with its label, then again prepared. Plan for about three times the bytes you allow.
- Not for folders. Theme folders and drop-ins under
wp-content/easy-svg-iconsuseeasy_svg_pro_source_max_iconsinstead.