Insert media automatically adding shortcode for pdf
-
Thank you for the plugin, I find it really useful.
In order to increase the usability of the plugin, the shortcode to display the pdf could automatically be inserted in place of the a tag when the user insert a pdf in the article through the ‘Insert Media’ button.
The following code added to the pdfjs-viewer.php does that:
function pdfjs_media_insert( $html, $id, $attachment ) { if ( preg_match( "/\.pdf$/i", $attachment['url'] ) ) { return '[pdfjs-viewer url="' . $attachment['url'] . '"]'; } else { return $html; } } add_filter( 'media_send_to_editor', 'pdfjs_media_insert', 10, 3 );
Feel free to add it to the next version of the plugin.
https://www.ads-software.com/plugins/pdfjs-viewer-shortcode/
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Insert media automatically adding shortcode for pdf’ is closed to new replies.