Skip to main content

gfpdf_allowed_local_folders

Description​

PDFs can only load local files, such as images and stylesheets referenced by absolute path, from these folders:

  • The WordPress install and home folders
  • The wp-content and uploads folders
  • Gravity PDF's working directory, fonts and temporary folders

Files outside these folders are skipped. Files loaded by URL (https://...) aren't affected, but have their own limits. Gravity Forms File Upload folders outside the web root are allowed automatically for that entry's PDF.

Use this filter when a template needs to load files from another folder.

If a file is a symlink, also list the folder its target is in. Windows network shares (\\server\share) are only read when listed.

Version​

This filter was introduced in Gravity PDF 6.18.2.

Parameters​

$folders | array​

  • Absolute paths to the allowed folders.

Usage​

Allow PDFs to load images from a folder outside the WordPress install:

add_filter( 'gfpdf_allowed_local_folders', function( $folders ) {
$folders[] = '/var/www/shared-assets';

return $folders;
} );

Source Code​

This filter is located in the Helper_Misc::get_allowed_local_folders() method of /src/Helper/Helper_Misc.php.