Installation Instructions
Install the plugin in the standard way via the ‘Plugins’ menu in WordPress and then activate.
To install Ghostscript, see How to install Ghostscript on the official Ghostscript site. For Ubuntu users, there’s a package:
sudo apt-get install ghostscript
For Windows, there’s an installer available at the Ghostscript download page.
What filters are available?
Three plugin-specific filters are available:
gopp_editor_set_resolution
sets the resolution of the PDF preview.
gopp_editor_set_page
sets the page to render for the PDF preview.
gopp_image_gs_cmd_path
short-circuits the determination of the path of the Ghostscript executable on your server.
The gopp_editor_set_resolution
filter is an analogue of the standard wp_editor_set_quality
filter mentioned above, and allows one to override the default resolution of 128 DPI used for the PDF preview. For instance, in your theme’s “functions.php”:
function mytheme_gopp_editor_set_resolution( $resolution, $filename ) {
return 100;
}
add_filter( 'gopp_editor_set_resolution', 'mytheme_gopp_editor_set_resolution', 10, 2 );
Similarly the gopp_editor_set_page
filter allows one to override the default of rendering the first page:
function mytheme_gopp_editor_set_page( $page, $filename ) {
return 2; // Render the second page instead.
}
add_filter( 'gopp_editor_set_page', 'mytheme_gopp_editor_set_page', 10, 2 );
The gopp_image_gs_cmd_path
filter is necessary if your Ghostscript installation is in a non-standard location and the plugin fails to determine where it is (if this happens you’ll get a Warning: no Ghostscript! notice on activation):
function mytheme_gopp_image_gs_cmd_path( $gs_cmd_path, $is_win ) {
return $is_win ? 'D:\\My Ghostscript Location\\bin\\gswin32c.exe' : '/my ghostscript location/gs';
}
add_filter( 'gopp_image_gs_cmd_path', 'mytheme_gopp_image_gs_cmd_path', 10, 2 );
The filter can also be used just for performance reasons, especially on Windows servers to save searching the registry and directories.
Note that the value of gs_cmd_path
is cached as a transient by the plugin for performance reasons, with a lifetime of one day. You can clear it by de-activating and re-activating the plugin, or by manually calling the clear
method of the Ghostscript Image Editor:
function mytheme_gopp_init() {
if ( class_exists( 'GOPP_Image_Editor_GS' ) ) {
GOPP_Image_Editor_GS::clear();
}
}
add_filter( 'init', 'mytheme_gopp_init' );
or for WP-CLI users:
wp transient delete gopp_image_gs_cmd_path