如何在CakePHP模板文件(default.ctp)上显示图像使用Bootstrap [英] How to display Images on CakePHP template file (default.ctp) Using Bootstrap

查看:931
本文介绍了如何在CakePHP模板文件(default.ctp)上显示图像使用Bootstrap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在CakePHP中创建一个网站仪表板。我使用的是bootstrap 3.0。



1)我要显示 default.ctp 文件中的$ c> webroot / img 。



我希望该图像显示在缩略图(bootstrap) div。



我使用 html helper
ie, echo $ this-> Html-> image('img.png',array('alt'=&标签

$ 属性 b
$ b

但不工作。



编辑



这是我在bootstrap代码中的尝试。

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


解决方案

编辑: >
您正在将完整的图像标记放入图像的源中。请参阅此主题的食谱的HTML帮助: http://book.cakephp.org/2.0 /en/core-libraries/helpers/html.html



因此,如果您替换此行:

 < img data-src =holder.js / 100%x100src =<?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')); ?> 

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 the default.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 the source attribute of img 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>

解决方案

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.

这篇关于如何在CakePHP模板文件(default.ctp)上显示图像使用Bootstrap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆