エントリーの編集
エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
記事内の一番最初の画像を自動で表示する『catch_that_image()』でうまく最初の画像が取得できない
記事へのコメント0件
- 注目コメント
- 新着コメント
このエントリーにコメントしてみましょう。
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています
- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
記事内の一番最初の画像を自動で表示する『catch_that_image()』でうまく最初の画像が取得できない
<?php function catch_that_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_cle... <?php function catch_that_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ //Defines a default image $first_img = "画像がない場合の画像の場所"; } return $first_img; } ?>