首页 > 解决方案 > 蛋糕PHP。如何给出显示图像的路径

问题描述

目前,我给出了这条行不通的路径。

<img src=<?= @$this->Url->build("/images/categori/{$product->thumb}") ?> alt="" class="img-fluid" width="255" height="280">

但是,我想给出的路径是这样的。

echo $this->Html->image    

标签: phphtmlcakephpcakephp-3.0cakephp-2.0

解决方案


尝试:

<?= $this->Html->image(sprintf('/images/categori/%s', $product->thumb),
[
    'alt' => '',
    'class' => 'img-fluid', 
    'width' => 255, 
    'height' => 280
]); ?>

阅读:https ://book.cakephp.org/4/en/views/helpers/html.html#linking-to-images


推荐阅读