「関数リファレンス/BcBaser getImg」の版間の差分
提供: baserCMS公式ガイド
行4: | 行4: | ||
## 使い方 | ## 使い方 | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
− | $this->BcBaser->getImg( $path , [$options] ); | + | <?php $this->BcBaser->getImg( $path , [$options] ); ?> |
</syntaxhighlight> | </syntaxhighlight> | ||
行22: | 行22: | ||
## 戻り値 | ## 戻り値 | ||
+ | (string) | ||
画像タグ | 画像タグ | ||
行28: | 行29: | ||
####コード | ####コード | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
− | <?php $this->BcBaser->getImg( $path , [$options] ); ?> | + | <?php echo $this->BcBaser->getImg( $path , [$options] ); ?> |
</syntaxhighlight> | </syntaxhighlight> | ||
行39: | 行40: | ||
####コード | ####コード | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
− | <?php $this->BcBaser->getImg("/common/img/logo.png", array('alt'=>'この画像の代替テキストです', 'class'=>'testImg', 'width'=>'200px', 'height'=>'160px') ); ?> | + | <?php echo $this->BcBaser->getImg("/common/img/logo.png", array('alt'=>'この画像の代替テキストです', 'class'=>'testImg', 'width'=>'200px', 'height'=>'160px') ); ?> |
</syntaxhighlight> | </syntaxhighlight> | ||
2015年4月22日 (水) 17:40時点における版
目次
説明
画像タグを取得します。
使い方
<?php $this->BcBaser->getImg( $path , [$options] ); ?>
パラメータ
- (string)$path
-
画像のパス(img フォルダからの相対パス)。先頭にスラッシュをつけた場合は、/app/webroot/ からのパスとなる。スラッシュをつけず相対パスとした場合は、/app/webroot/img/ からのパスとなる。
- 初期値:−
- (array)$options
- 要素の属性等を連想配列で指定する。
- ※ パラメータについては、HtmlHelper::image() を参照。
- class / alt 等
-
例)array('class'=>'hoge')
- 初期値:array()
戻り値
(string) 画像タグ
用例
基本
コード
<?php echo $this->BcBaser->getImg( $path , [$options] ); ?>
出力
<img src="/app/webroot/common/img/logo.png">
応用
コード
<?php echo $this->BcBaser->getImg("/common/img/logo.png", array('alt'=>'この画像の代替テキストです', 'class'=>'testImg', 'width'=>'200px', 'height'=>'160px') ); ?>
出力
<img src='/app/webroot/common/img/logo.png' alt='この画像の代替テキストです' class='testImg' width='200px' height='160px'>