When it fires
In a sync of the knowledge base, for each PDF, before its file is read. A PDF larger than the limit is not read: the sync records the error “PDF is larger than the limit” for it and goes on with the next post.
The whole file is read and parsed in PHP’s memory, so the limit protects the sync from running out of memory. Before you raise it, make sure PHP’s memory_limit leaves room for a file several times that size; a sync that runs out of memory stops for every post after it.
Parameters
| Name | Type | Description |
|---|---|---|
max_bytes | int | The limit, 20 MB (20971520 bytes) by default. |
attachment | WP_Post | The PDF’s attachment post. |
Returns
int: The limit in bytes.
Example
add_filter(
'kimaai_embedding_pdf_max_bytes',
function (int $max_bytes): int {
// The product manuals are up to 50 MB; the server has the memory for them.
return 50 * 1024 * 1024;
}
);
Related
kimaai_embedding_pdf_extracted_text: changes the text read from a PDF.kimaai_embedding_supported_sources: the sources a sync can index, PDFs among them.