# How to load img with \<img\> tag on ctp view file? instead of html helper?u

**URL:** <https://discourse.cakephp.org/t/how-to-load-img-with-img-tag-on-ctp-view-file-instead-of-html-helper-u/6954>\
**Category:** Need Help\
**Created:** [December 3, 2019, 6:55pm UTC](https://discourse.cakephp.org/t/how-to-load-img-with-img-tag-on-ctp-view-file-instead-of-html-helper-u/6954 "2019-12-03T18:55:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![samuk190](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/samuk190/32/1593_2.png) [@samuk190](https://discourse.cakephp.org/u/samuk190)\
**Post date:** [December 3, 2019, 6:55pm UTC](https://discourse.cakephp.org/t/how-to-load-img-with-img-tag-on-ctp-view-file-instead-of-html-helper-u/6954/1 "2019-12-03T18:55:53Z")

</div>

Example  
\<img src=imagens/p.png width=\<?php echo $fino?\> height=\<?php echo $altura?\> border=0\>  
There’s a layout which was made by another developer of my team, and I need to implement it on cake php, but all images are made with img src html tag, I’ve seen on the docs that it should be done with $this-\>html , when I do that, I get a error Using $this when not in object context  
and plus it would be alot of effort, transforming every img src into $this-\>Html-\>image

Also, if it is to be done with $this-\>Html-\>image, I dont know how to pass the attribute border=0.  
my folder imagens is on webroots folder

I saw my mistake right now, $this-\>Html-\>image is inside a function, how I can solve this?

---

<div class="post-metadata">

**Author:** ![jimgwhit](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/jimgwhit/32/378_2.png) [@jimgwhit](https://discourse.cakephp.org/u/jimgwhit)\
**Post date:** [December 7, 2019, 10:34pm UTC](https://discourse.cakephp.org/t/how-to-load-img-with-img-tag-on-ctp-view-file-instead-of-html-helper-u/6954/2 "2019-12-07T22:34:47Z")

</div>

A normal tag works

```auto
<td><img width="100" style="border: none;" src="<?php echo DIR . 'img/upload/' . $row->dogpic; ?>" alt=""></a></td>

```

Where DIR is a constant to my base url. Just supply your base.

Just for reference here is helpers with making the image a link also:

```auto
                echo '<td>';
                    echo $this->Html->link(
                            $this->Html->image('imgdogs/' . $row->dogpic, array(
                                'class' => 'image',
                                'alt' => ''
                            )), array(
                        'controller' => 'Dogs',
                        'action' => 'view', '?' => ['dogid' => $row->dogid]
                            ), array(
                        'class' => 'imgtd',
                        'escape' => false //to allow the image tag within the link
                            )
                    );
                    echo '</td>';

```

---

<div class="post-metadata">

**Author:** ![Salines](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/salines/32/3166_2.png) [@Salines](https://discourse.cakephp.org/u/Salines)\
**Post date:** [December 10, 2019, 1:06pm UTC](https://discourse.cakephp.org/t/how-to-load-img-with-img-tag-on-ctp-view-file-instead-of-html-helper-u/6954/3 "2019-12-10T13:06:26Z")

</div>

Start **src** path with slash, example /img/avatar.png, /css/style.css, /js/script.js, /files/book.pdf, /music/free.mp3, etc

`<img src="/imagens/p.png" width="<?php echo $fino?>" height="<?php echo $altura?>" border="0">`
