Wordpress简码:简单嵌入PDF

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Wordpress简码:简单嵌入PDF相关的知识,希望对你有一定的参考价值。

  1. /*
  2.  * Code modified by: Street.Walker [at] masedi [dot] net
  3.  * Simple embedding PDF, Presentation file to blog post with Google view.
  4.  * ex: http://docs.google.com/viewer?url=http://infolab.stanford.edu/pub/papers/google.pdf&embedded=true
  5.  * or: http://docs.google.com/gview?url=http://infolab.stanford.edu/pub/papers/google.pdf&embedded=true
  6.  * embed it with html iFrame: <iframe src="http://docs.google.com/gview?url=http://infolab.stanford.edu/pub/papers/google.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>
  7.  * Source from: http://googlesystem.blogspot.com/2009/09/embeddable-google-document-viewer.html
  8.  * implementation for WordPress: use shortcodes
  9.  * usage: [embedpdf width="600px" height="500px"]http://infolab.stanford.edu/pub/papers/google.pdf[/embedpdf]
  10.  * adopted from: http://www.wprecipes.com/wordpress-tip-create-a-pdf-viewer-shortcode
  11.  *
  12.  * Copy the code and paste it to your functions.php file under your active theme
  13.  */
  14.  
  15. function viewpdf($attr, $url) {
  16. return '<iframe src="http://docs.google.com/viewer?url=' . $url . '&embedded=true" style="width:' .$attr['width']. '; height:' .$attr['height']. ';" frameborder="0">Your browser should support iFrame to view this PDF document</iframe>';
  17. }
  18. add_shortcode('embedpdf', 'viewpdf');

以上是关于Wordpress简码:简单嵌入PDF的主要内容,如果未能解决你的问题,请参考以下文章

wordpress 移动主题删除简码

WordPress Shortcode(简码)介绍及使用详解

在网站上动态嵌入 youtube 频道的最佳方式是啥(首选 wordpress)

无法解析 acf 字段中的简码(wordpress)

显示每月第一个工作日的 WordPress 函数和简码

WordPress - 覆盖简码