How to display Images on CakePHP template file (default.ctp) Using Bootstrap
Solution 1
Edit:
You are placing a complete image tag into an image's source. See the cookbook's HTML helper for this topic: http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html
So if you replace this line:
<img data-src="holder.js/100%x100" src="<?php $this->Html->image('img.png', array('alt' => 'CakePHP', 'border' => '0')); ?>" />
With this line:
<?php echo $this->Html->image('img.png', array('alt' => 'CakePHP', 'border' => '0', 'data-src' => 'holder.js/100%x100')); ?>
that should do the trick.
Solution 2
You can try like this
$this->Html->image('img.png', array('alt' => 'CakePHP'));
Girish Thimmegowda
Facebook - https://www.facebook.com/imgirishyt Twitter - https://twitter.com/girishyt Email - [email protected]
Updated on July 04, 2020Comments
-
Girish Thimmegowda almost 4 years
I'm creating a Website Dashboard in CakePHP.. And i'm using bootstrap 3.0.
1) I want to display an image present in
webroot/img
in thedefault.ctp
file.2) I want that image to be displayed inside the
thumbnails( bootstrap )
div.I used
html helper
ie,echo $this->Html->image('img.png', array('alt' => 'CakePHP'));
for thesource
attribute ofimg
tag.but not working..
Edit
This is how i have tried within bootstrap code.
<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>