個人用ツール

「関数リファレンス/BcBaser getImg」の版間の差分

提供: baserCMS公式ガイド

移動: 案内, 検索
(ページの作成:「## 説明 画像タグを取得します。 ## 使い方 <syntaxhighlight lang="php"> $this->BcBaser->getImg( $path , [$options] ); </syntaxhighlight> ## パラメー...」)
 
 
(2人の利用者による、間の3版が非表示)
行4: 行4:
 
## 使い方
 
## 使い方
 
<syntaxhighlight lang="php">
 
<syntaxhighlight lang="php">
$this->BcBaser->getImg( $path , [$options] );
+
<?php $this->BcBaser->getImg( $path , [$options] ); ?>
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
## パラメータ
 
## パラメータ
$path
+
(string)$path
: 画像ファイルまでのパス。先頭にスラッシュをつけた場合は、/app/webroot/ からのパスとなる。スラッシュをつけず相対パスとした場合は、/app/webroot/img/ からのパスとなる。
+
: 画像のパス(img フォルダからの相対パス)。先頭にスラッシュをつけた場合は、/app/webroot/ からのパスとなる。スラッシュをつけず相対パスとした場合は、/app/webroot/img/ からのパスとなる。
  
 
     - 初期値:−
 
     - 初期値:−
  
$options
+
(array)$options
 
: 要素の属性等を連想配列で指定する。
 
: 要素の属性等を連想配列で指定する。
 +
: ※ パラメータについては、HtmlHelper::image() を参照。
 
: class / alt 等
 
: class / alt 等
 
: 例)array('class'=>'hoge')
 
: 例)array('class'=>'hoge')
行21: 行22:
  
 
## 戻り値
 
## 戻り値
 
+
(string)
 +
画像タグ
  
 
## 用例
 
## 用例
行27: 行29:
 
####コード
 
####コード
 
<syntaxhighlight lang="php">
 
<syntaxhighlight lang="php">
<?php $this->BcBaser->getImg( $path , [$options] ); ?>
+
<?php echo $this->BcBaser->getImg( $path , [$options] ); ?>
 
</syntaxhighlight>
 
</syntaxhighlight>
  
行38: 行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>
  
行57: 行59:
 
[getImg](/関数リファレンス/getImg)
 
[getImg](/関数リファレンス/getImg)
  
[[Category:関数]]
+
 
 +
[[Category:関数リファレンス]]

2016年3月29日 (火) 16:09時点における最新版

説明

画像タグを取得します。

使い方

<?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'>

変更履歴

ソースファイル

関連資料

類似の関数

getImg