如何将大小参数添加到IMG



如何将大小参数添加到我的WordPress图像?

我用于缩略图的代码为:

if (has_post_thumbnail())
{
    the_post_thumbnail('full');
}

我只想从

更改图像的URL
<img src="website.com/wp-content/uploads/img.jpg">

to

<img src="website.com/wp-content/uploads/img.jpg?size=10">

使用get_the_post_thumbnail_url((仅获取帖子图片的URL并使用此URL创建<img />标签。

if (has_post_thumbnail())
{
    echo '<img src="'.get_the_post_thumbnail_url(null, 'full').'?size=10" alt="" />';
}

最新更新