■ユーザーズフォーラム リニューアルのお知らせ
新規投稿は新ユーザーズフォーラムにお願いします。

記事中の画像がない場合の画像を出力する方法

sgrnsn > 記事中の画像がない場合の画像を出力する方法 @ 2011/5/28 13:50
お世話になります。

<?php $blog->postImg($post) ?>


で記事の中の画像を出力する方法は確認できたのですが
記事の中に画像がない場合、どのように修正を加えたら宜しいでしょうか?

最新バージョン(1.6.11.3)の
basercms\baser\plugins\blog\views\helpers\blog.php
の513行目から変更を加える事で問題解決できると感じてはおりますが
その方法がいまいち分かりません。

	function postImg($post, $options = array()) {

		$this->setBlogContent($post['BlogPost']['blog_content_id']);
		$_options = array('num' => 1, 'link' => true, 'alt' => $post['BlogPost']['name']);
		$options = am($_options, $options);
		extract($options);
		unset($options['num']);
		unset($options['link']);
		
		$contents = $post['BlogPost']['content'].$post['BlogPost']['detail'];
		$pattern = '/<img.*?src="([^"]+)"[^>]*>/is';
		if(!preg_match_all($pattern, $contents, $matches)){
			return '';
		}

		if(isset($matches[1][$num-1])) {
			$url = $matches[1][$num-1];
			$img = $this->Baser->getImg($url, $options);
			if($link) {
				$this->Baser->link($img, $url = array('admin'=>false,'plugin'=>'','controller'=>$this->blogContent['name'],'action'=>'archives', $post['BlogPost']['no']));
			} else {
				echo $img;
			}
		} else {
			return '';
		}
		
	}


大変お手数ではございますが、ご教授頂きます様
宜しくお願い致します。

--------------------------------------------------------

スタイルシートにて自己解決致しました。
ありがとうございました。
ログイン
ユーザー名:
パスワード:


  新規登録 / パスワード紛失

検索

facebook
フォーラムで悩みが解決した場合など、よかったら「いいね!」をポチっとクリックしてください!質問の回答者や開発者の励みになります

フォーラムガイド


関連リンク

オンライン状況
33 人のユーザが現在オンラインです。 (33 人のユーザが フォーラム を参照しています。)

登録ユーザ: 0
ゲスト: 33