DataTables Print - How to display images and URLs

By default, DataTables's Print button, doesn't include images or link URLs.

With the help of this code snippet below, images and URLs will be visible when the page is printed.

document.addEventListener('DOMContentLoaded', function() {
	wp.hooks.addFilter( 'gk.datatables.options', 'dt-custom-code', function ( options ) {
		options.buttons = options.buttons.map( button => {
			if ( 'print' === button.extend ) {
				button.exportOptions = {
					stripHtml: false
				}
			}
			return button;
		} );	
		return options;
	} );
});

This JavaScript code should be copied and pasted, as it is, on the Custom JavaScript editor that sits inside View Editor > View Settings metabox > Custom Code tab.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us