$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>attachments - Can I attach a document (eg: PDF) but have a JPEG as a thumbnail?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

attachments - Can I attach a document (eg: PDF) but have a JPEG as a thumbnail?

matteradmin10PV0评论

Is there a built-in feature or plugin that allows you to attach a document to a post or page such that the actual attachment file is one thing (eg a PDF) but the thumbnail images are another (eg a JPEG)? CLARIFICATION: the thumbnail does not need to be automatically generated (it could be a separate upload)

The use case here is a document library, where you have a little screenshot of what that document looks like but when you click the attachment, you can download the original document.

Is there a built-in feature or plugin that allows you to attach a document to a post or page such that the actual attachment file is one thing (eg a PDF) but the thumbnail images are another (eg a JPEG)? CLARIFICATION: the thumbnail does not need to be automatically generated (it could be a separate upload)

The use case here is a document library, where you have a little screenshot of what that document looks like but when you click the attachment, you can download the original document.

Share Improve this question edited Aug 26, 2011 at 15:47 Tom Auger asked Aug 26, 2011 at 12:49 Tom AugerTom Auger 7,1069 gold badges63 silver badges85 bronze badges 8
  • 2 I don't know any plugins that can do this but that doesnt stop you extending WP to do this. stackoverflow/questions/467793/… there is a start. This will allow you to convert pdf to image in PHP – Scott Commented Aug 26, 2011 at 13:16
  • Note that I'm not necessarily suggesting that the image thumbnail should be automatically generated. Just have the ability to upload a separate JPG or PNG and associate it as the thumbnail with a larger file. – Tom Auger Commented Aug 26, 2011 at 15:46
  • 1 I could have sworn I saw something that could associate an uploaded image with another media file, but I cannot locate it for the life of me. This looks like a promising direction, but I have no idea if it actually works or not: xplus3/2008/11/17/custom-thumbnails-wordpress-plugin – helenhousandi Commented Aug 26, 2011 at 19:12
  • @helenhousandi brilliant blog post. I'ma try the plugin now, see how well it works. – Tom Auger Commented Aug 28, 2011 at 17:32
  • @helenhousandi well, the plugin appears to be broken in WP 3.2.1, but there's a lot of good code in there that might be salvageable. I'll post back if I write a plugin – Tom Auger Commented Aug 28, 2011 at 17:38
 |  Show 3 more comments

5 Answers 5

Reset to default 2

Good news for this old question, since WordPress 4.7, pdf's thumbnail are automatically generated.

Basic HTML?

<a href="your.pdf">
<img src="image.jpg" />
</a>

When you insert and image there is a field for the url called Link URL, you can just put your download url there.

Please at least explain the down vote, I'm pretty certain this answers the OP's question.

WP-Filebase ended up being the free plugin solution we went with. This is actually a pretty cool plugin with a lot of power under the hood, though the interface is far from slick. When you upload any kind of document, you have the option to go to an "Advanced" upload form, which allows you to upload a separate thumbnail for the document. Then, when you decide to list the document, whether using shortcode, or automatically linking the doc to a page, you'll see the thumbnail instead. Unfortunately, no ability to generate / manipulate / scale the thumbnail unlike the native Media upload process. Still, it's a useful tool with some basic Document Management features that make it a good fit for small DMS requirements.

Try this plugin. It has features that you need: Advanced Custom Fields

Its free, But if you need repeater feature, you'll need to purchase the license key.

Wordpress already have the mechanism. We solve this by adding support for post-thumbnail (featured image) for attachments, and handle the representation for each file as normally do for other post types. (if has post thumbnail: the_post_thumbnail() etc etc.) Just add to functions.php:

function entex_add_attachment_support(){
      add_post_type_support('attachment', 'thumbnail');
}
add_action('after_setup_theme', 'entex_add_attachment_support');

Make shure to make the template files to look for the thumbnail, or filter in by hooks. There are plenty of ways to implement this solution. It feels a little confusing at the beginning to have featured image for an image, but its really handy for many objectives. You can also filter in to "read" this in Library table etc etc.

Post a comment

comment list (0)

  1. No comments so far