The only reliable cross browser solution is to embed the .pdf in a iframe
.
add_filter('media_send_to_editor', 'my_pdf_embed', 20, 3);
function my_pdf_embed($html, $id) {
$attachment = get_post($id); //fetching attachment by $id passed through
$mime_type = $attachment->post_mime_type; //getting the mime-type
if ($mime_type == 'application/pdf') { //checking mime-type
$src = wp_get_attachment_url( $id );
//change the size to your liking
$html="<iframe width="500" height="500" src="".$src.'"></iframe>';
return $html; // return new $html
}
return $html;
}
Related Posts:
- How to upload PDF from Front-End and post automatically?
- SWF in wordpress post
- New posts are not showing up on my front page
- Javascript embedded disappears for editors
- WordPress is redirecting me to homepage
- Is there a hook similar to “save_post” which only fires AFTER the post is completely published?
- Looking for WordPress PDF Converter with Custom Templates?
- FPDF for creating pdf diplomas
- Adding custom post category to categories widget
- How to display the custom post related blog by category?
- WP Forms not displaying,becomming an fatal error
- Randomize post (and page) IDs on generation
- Moving all wordpress posts from 50 websites to another website
- WordPress hide post from custom post-type on a single page
- How can I see $post object in frontend from functions.php?
- Show post object of any page in frontend
- .com creates automated link in post
- Allow members to create groups on my site
- Trying to add a new feature in my wordpress website
- Powerpress upload a podcast without creating a post for it
- automatically set random featured image by category in wordpress on post
- add tags to wordpress post using REST API
- Is it possible to customize a wordpress post from outside dashboard(Something like site.com/post-type/post/?e=post_id)?
- Prefix WordPress Taxonomy Tags With Hashtag Symbol Like Twitter
- Pagination (including title of each page) in a post for a long posts
- How to make a page both “private” and “password protected”
- PDF Viewer Origin is Different
- Failed to load resource: the server responded with a status of 500 () post.php
- How to echo a PHP Code After the Content
- All Post WordPress Page Error
- WordPress Product Detail and catalog
- How to fix blog article view and share #’s?
- Is it possible to create duplicate post on other site (either push, on publish, or pull, periodically)?
- How to wrap image tag into div for post only?
- How to create multiple pages for PDFs
- How can I get the Post ID and Post Type within a Must Use Plugin?
- WordPress CPT Url metabox collection
- Get value from an input field and pass into update_meta_data as $meta_value
- Identify if the_post hook is being called from the admin post list
- My own metabox checkbox plugin only saves the last value I’ve checked
- Get content and send to 3rd party
- How to prevent authors from editing their post count?
- Add dynamic color to each category item
- Include post_date in search
- Add Filter to get_next_posts_link
- Is there any hook to change media html in post? [duplicate]
- Is it possible to get a shortcode generated by a plugin, then, using a function, create a new post using that shortcode?
- How to Save settings of custom tab product page in admin side in a database?
- How to force regenerate thumbnails in WordPress posts?
- Displaying friend’s posts only
- WordPress Dashboard organize posts based on categories
- Add new post using a page inside the website
- Trending Tags based on post views
- Publish Post but don’t call publish hook in foreground post creation
- Hidden Some Setting on Post or Page [duplicate]
- Different email notifications (about pending posts) to different users
- How to display single arbitrary facebook post with a shortcode?
- Better code/text editing for posts and pages?
- Custom post type request switches to media request
- Serialize $_POST global in wordpress
- WordPress list child pages of custom post type
- Style WordPress Custom Post Type Single Page
- How to use shortcode of any plugin to show it visually where i want?
- WordPress not updating post or disable plugin instead a white page appear
- get post excerpt by query
- Ger posts from similar tags and categories
- Related posts popup
- Posts are deleted everyday at night
- How to Batch Upload .docx Files as Posts
- Internationalization of Blog Posts
- Issues with Post 2 Post Plugin
- Find And Add Category to Posts
- Retrieve post thumbnails
- WordPress ultra slow if I click on posts?
- Enforce conditions only for draft posts using WyPiekacz, ignore pending and published posts
- How to add character to content of post?
- Get page type to display content
- Insert data in custom table during new post creation
- Capturing POST data
- single.php fires more than once after clicking on any post to view with different post id each time
- Twitter List Tweets and Delicious Links as Posts
- Most visited posts
- Get a submitted value from front end post form for single template
- Can someone please help me find a solution to my youtube embed problems? [duplicate]
- Using Postmash plugin in WordPress 3.3.1
- What is the correct method for updating post content from a plugin?
- Custom feed parameters / Template overriding
- How to make only selected posts appear on a selected wordpress page
- Automatically set posts to NoIndex depending on category?
- Get post id in Post Page within Wp-admin
- wp_update_post does not change post status from draft to publish, returns 1
- Notification When Post Approved
- PHP $_session is not work in wordpress
- Embedding BitBucket Code in Posting
- Static page with formatted post list
- Next and Previous Pagination button not displaying in WordPress
- How to block external download link access if visitor not referred from WP?
- Plugin to display text before a post
- Notifications on WordPress Website [closed]
- Automatically put a menu on every post