apply_filters( 'relevanssi_get_attached_file', string $filename, int $post_id )

Filters the attachment file name Relevanssi uses when reading attachment content. If you want to read content from attachments that are stored outside Media Library, you need to modify this value.


(string) The attachment URL, defaults to get_attached_file( $post_id ).

(int) The attachment post ID.

More information

When reading attachment contents, Relevanssi uses by default the get_attached_file() function to get the attachment file path. If you keep your attachments in the Media Library, this is fine, but if you’re not using Media Library, this function will not return the correct value.

In that case, you need to use this filter hook to provide an alternate method of getting the filename. The exact method depends on what you’re trying to implement, but this filter hook expects you to provide a full path to the attachment specified by the post ID.

You also need to modify relevanssi_get_attachment_posts_query and may need to modify relevanssi_get_attachment_url.