WordPress の自動メディアリンクにメディア形式を追加する


WordPress 2.9  oEmbed () 便
YouTube  Flickr  URL 稿 URL  YouTube  Flickr 




YouTube

Vimeo

DailyMotion

blip.tv

Flickr (both videos and images)

Viddler

Hulu

Qik

Revision3

Scribd

Photobucket

PollDaddy

Google Video

WordPress.tv VideoPress 

SmugMugWordPress 3.0 

FunnyOrDie.comWordPress 3.0  


)使


wp_embed_register_handler() 使

PDF 


pdf Google Docs Viewer  functions.php 
function wp_embed_handler_pdf( $matches, $attr, $url, $rawattr ) {
 $width = 600;
 $height = 780;
 $embed = sprintf(
   '<iframe src="http://docs.google.com/viewer?url=%1$s&embedded=true" width="%2$d" height="%3$d" style="border: none;"></iframe>',
   esc_attr(rawurlencode($matches[0])),
   (int) $width,
   (int) $height
   );
 return apply_filters( 'embed_pdf', $embed, $matches, $attr, $url, $rawattr );
}
wp_embed_register_handler( 'pdf', '/^https?(:\/\/[-_\.!~*\'()a-zA-Z0-9;\/:\@=+\$,%#]+)(\.pdf)$/', 'wp_embed_handler_pdf' );


http://demo.dogmap.jp/2011/01/26/wp_embed_register_handler-test/


 functions.php 
function wp_embed_handler_nicovideo( $matches, $attr, $url, $rawattr ) {
 $vid = esc_attr($matches[1]);
 $width = 485;
 $height = 385;
 $embed = sprintf(
  '<div id="nicovideo-%3$s"><iframe width="%1$d" height="%2$d" src="http://www.nicovideo.jp/thumb/%3$s" scrolling="no" style="border:solid 1px #CCC;" frameborder="0"><a href="%4$s">%4$s</a></iframe></div>',
  (int) $width,
  (int) $height,
  $vid,
  esc_attr($matches[0])
  );

 $embed .= "<script type=\"text/javascript\">
jQuery(function(){
 var output = [];
 document._write = document.write;
 document.write = function(v){ output.push(v); }
 jQuery.getScript('http://ext.nicovideo.jp/thumb_watch/{$vid}', function(){
  jQuery('#nicovideo-{$vid}').html(output.join(''));
  output = [];
  document.write = document._write;
 });
})
</script>";
 return apply_filters( 'embed_pdf', $embed, $matches, $attr, $url, $rawattr );
}
wp_embed_register_handler( 'nicovideo', '/https?:\/\/www\.nicovideo\.jp\/watch\/(sm[\d]+)([\?])?([-_\.!~*\'()a-zA-Z0-9;\/:\@=+\$,%#]+)?/i', 'wp_embed_handler_nicovideo' );
wp_enqueue_script('jquery');


http://demo.dogmap.jp/2011/01/26//


WordPress の自動メディアリンクにメディア形式を追加する」への3件のフィードバック

  1. saya806

    ニコニコ動画の張り付けに関して、こちらでも試しているのですが、
    ・貼り付ける動画の大きさを変えても、フルサイズ固定になってしまう
    ・ページ内につき1枚しか動画は貼り付けられない
    という問題があるようです。

    返信
  2. ピンバック: wordpressで画像アップが億劫な人へ | ぴとり.net

  3. ピンバック: Tweets that mention WordPress の自動メディアリンクにメディア形式を追加する : dogmap.jp -- Topsy.com

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください