【发布时间】:2023-03-12 11:24:01
【问题描述】:
我在尝试使用内联样式设置 div 的背景图像时遇到问题(以显示帖子中的特色图像)。简码类似于:
[all-systems]
处理函数是这样的:
$markup = '';
$img = get_the_thumbnail(...);
// if I die($img) at this point, I am getting a valid link to my image like
// http://somedomain.com/wp-content/uploads/2015/03/pic.jpg
$markup .= "<div style='background-image('" . $image . "')>...</div>";
return $markup;
短代码吐出的结果标记是正确的,但我的background-image url 中的/ 缺失并替换为空格。所以背景图像实际上看起来像:
http: mydomain.com wp-content upload 2015 03 pic.jpg
这是 wordpress 正在“帮助”我的一项保护措施吗?反正围绕这个?
【问题讨论】:
标签: html css wordpress shortcode