2013-08-24 38 views
2

我在CakePHP中創建網站儀表板。並且我使用引導程序3.0。如何在CakePHP模板文件(default.ctp)上顯示圖像使用引導程序

1)我想在default.ctp文件中顯示webroot/img中的圖像。

2)我想要該圖像顯示在thumbnails(bootstrap) div內。

我用html helperecho $this->Html->image('img.png', array('alt' => 'CakePHP'));img標籤的source屬性。

,但沒有工作..

編輯

這是我如何引導代碼內接受審判。

<div class="row" 
    <p><b>Target Image</b></p> 
    <div class="col-lg-3 col-md-3 col-sm-3"> 
     <a href="#" class="thumbnail"> 
      <img data-src="holder.js/100%x100" src="<?php $this->Html->image('img.png', array('alt' => 'CakePHP', 'border' => '0')); ?>" /> 
      </a> 
    </div> 
</div> 

回答

9

編輯:
您將一個完整的圖像標記成圖像的源。查看菜譜的HTML幫助這個話題:http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html

因此,如果您替換此行:

<img data-src="holder.js/100%x100" src="<?php $this->Html->image('img.png', array('alt' => 'CakePHP', 'border' => '0')); ?>" /> 

這一行:

<?php echo $this->Html->image('img.png', array('alt' => 'CakePHP', 'border' => '0', 'data-src' => 'holder.js/100%x100')); ?> 

應該做的伎倆。

+0

號。「這 - $> HTML的「形象」指向「IMG」目錄隱含.. –

+0

然後你能證明所產生的HTML代碼? –

+0

多數民衆贊成多數民衆贊成在什麼問題是..如果我寫在引導縮略圖div之外,那麼它會顯示圖像..但我希望該圖像顯示在該框內..請看看編輯的代碼.. –

1

你可以嘗試這樣的

$this->Html->image('img.png', array('alt' => 'CakePHP')); 
0

爲了使持有人腳本正常工作img元素的src屬性不應設置好的。

所以,一個propoer的解決方案是:

<?php echo $this->Html->image('', array('alt' => 'CakePHP', 'border' => '0', 'data-src' => 'holder.js/100%x100')); ?> 
相關問題