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

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?

A normal tag works

<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:

                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>';
1 Like

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">

1 Like