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
- How Do I Use The WordPress Plugin Posts 2 Posts by Scribu?
- How to Add jQuery Infinite Scroll to My Custom Archive Page
- OEmbed from Pinterest
- publish_post hook isn’t working for scheduled posts
- How to get posts by content?
- Plugin for changing a post’s category based on it’s post date?
- Publish Post After Click On A Link
- Enable comments for post with comments meta box removed
- Edit/revise option for authors to suggest improvement to posts [closed]
- Is there an action that is called when a post is restored from the trash?
- plugin for wp_list_categories with posts
- Action on post publish
- Replace existing pages with new pages, keep menu links
- Adding “ ” before the last word in multiple defined areas with a plugin
- [Plugin: Posts 2 Posts] How does it work?
- Set attached to state
- How to add new tabs in post.php
- Building WordPress Plugin Using FPDF – How do you get post content from currently viewed post?
- How to change ID of an attachment in wp_posts and its related tables correctly?
- New post notification plugin [closed]
- Display comments of users on single page
- Adding Plugin-specific Fields with wp_insert_post()?
- Using the “Latest posts” feature on a different site
- Is there a way to order posts and custom post types as one group?
- How can i list random post from multiple category?
- Cron job not firing
- Is there an easy way to flag posts in the admin area?
- finding whether request is for post, and post id
- Can’t delete Draft Post [closed]
- Outbound link autometic converted into linkdirect , and not opening
- How to allow an editor to edit all WordPress blog posts but have the last say as administrator?
- Contributive page where people logged in can write
- Trying to fix form resubmition with PRG (Getting error: Cannot modify header information – headers already sent by)
- Display wordpress post’s in popup?
- Unable to add TAB character to post?
- How to display number of page views on a post?
- AJAX fileupload – TypeError: not a function ajaxSubmit()
- Recent posts per category loop?
- ‘Organize Series Plugin’ as muti author feature
- Problem of encoding characters (apostrophes) in my posts publications
- How to backup single post in wordpress [closed]
- Is there a way to make the main page only display a brief description of the full article?
- How to change the post form from plugin?
- WordPress plugin Post Creation [closed]
- Allowing users to Sign-up > Login > Post articles that need approval
- posts from multiple post types in one slider
- How to display the featured post on the category page?
- Set Multiple Meta Values as an Array Using dispatch( ‘core/editor’ ).editPost() Call in Gutenberg/JS
- Is there a plugin or a way in the wordpress that would let us have different versions of a post or page accessibe to users?
- download button for audio file in post [closed]
- Print posts category or tag as a formatted journal
- trigger email when post is published by someone a user follows
- Post deleted in trash [closed]
- How to relate 3 wordpress components with each other (Create database relationships)
- Hook Scripts and Styles in WordPress
- WordPress plugin: Getting posts where checkbox selected
- count the number of views of a post excluding own views
- How to auto strip hyperlinks & images in wordpress post
- WP Editor, save content and category on frontend
- Plugin for TinyMCE to create reference to other posts
- Rename Smart YouTube’s httpv back to http for all posts
- How to get Recent Post From Each Category with Thumbnail?
- help intercepting save_post through plugin
- How to use a shortcode or an application to dynamically embed content from one WordPress site to another?
- Why the internal link get converted into a comment?
- Copy/paste local images not working in WordPress
- How to change my 3000 Published post status to Draft using PHPMyAdmin
- .com creates automated link in post
- Is it possible to customize a wordpress post from outside dashboard(Something like site.com/post-type/post/?e=post_id)?
- PDF Viewer Origin is Different
- All Post WordPress Page Error
- 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)?
- WordPress CPT Url metabox collection
- Add dynamic color to each category item
- Is there any hook to change media html in post? [duplicate]
- Displaying friend’s posts only
- Publish Post but don’t call publish hook in foreground post creation
- Hidden Some Setting on Post or Page [duplicate]
- Better code/text editing for posts and pages?
- WordPress list child pages of custom post type
- Style WordPress Custom Post Type Single Page
- get post excerpt by query
- Enforce conditions only for draft posts using WyPiekacz, ignore pending and published posts
- Using Postmash plugin in WordPress 3.3.1
- What is the correct method for updating post content from a plugin?
- Get post id in Post Page within Wp-admin
- PHP $_session is not work in wordpress
- Embedding BitBucket Code in Posting
- Next and Previous Pagination button not displaying in WordPress
- Notifications on WordPress Website [closed]
- Sell “create a post”, paid account for post creation
- Shortcode returning specific content of a post
- Looking for membership style plugin with edit option [closed]
- Change from blogger to wordpress
- Disable auto-embed feature when pasting links in Gutenberg editor?
- Remove embed url for internal links
- Getting 400 Error in wordpress website