How I can link image

Hi, please I need help.
I need show image in Pages/img/LogAvatar.png

V%C3%BDst%C5%99i%C5%BEek

This line is in home.ctp:

<?php echo $this->Html->image('LogAvatar.png', ['alt' => 'picture]); ?>

And it show only text β€œpicture” :confused:

I’ve had no problems with

<td><?php echo $this->Html->image('imgdogs/' . $quy->dogpic, array(
                                'class' => 'imgborder',
                                'alt' => ''
                            )); ?></td>

Why are your scripts and images and everything in your Pages dir?
This should all be in your webroot according to the conventions.

See this tree to know what I mean:

/
β”œβ”€β”€ src
β”‚   └── Template
β”‚       └── Pages
β”‚           β”œβ”€β”€ view.ctp
β”‚           └── home.ctp
└── webroot
    β”œβ”€β”€ css
    β”‚  └── mystyles.min.css
    β”œβ”€β”€ js
    β”‚   └── whatever.min.js
    β”œβ”€β”€ img
    β”‚   └── LogAvatar.png
    └── index.php

You can then load the image in your view by using this code:

<?= $this->Html->image('LogAvatar.png',['alt'=>'picture']); ?>
1 Like