php - 如何使特色图像/缩略图具有响应性?
问题描述
我正在寻找一些代码,以使我的图像缩略图在我调整浏览器大小时以它们调整大小的方式响应,如果这有意义的话。所以我找到了这段代码,它有点工作:
if ( has_post_thumbnail() ) {
$image_src = wp_get_attachment_image_src( get_post_thumbnail_id(),’thumbnail’ );
echo '<img width="100%" src="' . $image_src[0] . '">';
}
唯一的问题是它给了我这个错误:
警告:使用未定义的常量 'thumbnail' - 假定为 ''thumbnail''
(这将在 PHP 的未来版本中引发错误)
所以我想知道是否有一种新的方法可以做到这一点。
谢谢!
解决方案
It looks like you have copied this code from somewhere else.
So in $image_src
image size thumbnail
have copied Single Quotes.
Remove that Quotes and try the default editor's Single or Double quote and try again.
推荐阅读
- c - 3 字节数组 - 时间格式 {Hour}{Minute}{Second}
- python - 如何为 PYPI 包提供持久存储
- php - 将表中的查询结果保存到变量中,然后将其发送到另一个表中
- javascript - 如何用''替换'/'?
- javascript - 将字母转换为逗号分隔的数字?
- r - 有没有办法删除遵循 R 中模式的数据帧行?
- azure-devops - 扩展 Azure 多阶段 yaml 管道日志
- c++ - C++ 和字符的整数值
- python-3.x - 我可以使用 np.mean 计算 4D 数组的两个不同轴的平均值吗?
- ios - 检索firebase信息以设置按钮标题