php - 蛋糕PHP。如何给出显示图像的路径
问题描述
目前,我给出了这条行不通的路径。
<img src=<?= @$this->Url->build("/images/categori/{$product->thumb}") ?> alt="" class="img-fluid" width="255" height="280">
但是,我想给出的路径是这样的。
echo $this->Html->image
解决方案
尝试:
<?= $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
推荐阅读
- laravel - 如何正确分组 Laravel Query Builder 中的 where 子句
- java - 从文件中读取对象 - 消失的引用
- sql-server - Azure AD 用户无法连接到 Azure SQL 错误:18456,状态:1,类:14
- django-views - 将变量传递给 Django 表单类
- php - MySQL连接表作为嵌套数组
- javascript - 无效的钩子调用 - useContext - React Hooks
- java - Jackson 多重抽象 Objet 序列化
- regex - 使用正则表达式和 glob 变量搜索文件名
- vba - 在 MS Access 中使用 VBA 在 SharePoint 上创建文件夹
- android - 谷歌应用购买选项,消除添加