apply_filters( 'relevanssi_file_content', string $content, int $post_id )

Filters the attachment content before it is saved in the _relevanssi_pdf_content custom field.


(string) The contents of the file.

(int) The post ID of the attachment post.

More information

As Relevanssi reads in the file contents, the data is received from the attachment reading server and then stored in the _relevanssi_pdf_content custom field of the attachment post. The file contents pass through this filter hook before they are stored in the custom field.

If you want to modify the file contents somehow before they are saved, this is the place. There have been some cases where the file contents have characters that the WordPress custom field system can’t digest, and this filter hook can be used to clean out those unwanted characters before the data is saved.

add_filter( 'relevanssi_file_content', 'rlv_modify_file_content' );
function rlv_modify_file_content( $content ) {
  // modify the content somehow here.
  return $content;