【发布时间】:2016-11-18 17:37:38
【问题描述】:
我目前已将此问题提交到 Wordpress 部分但没有成功。问题可以在here找到。
我正在使用此插件将图像附加到自定义分类。该插件的函数返回附加术语的图像如下:
function get_wp_term_image($term_id){
return get_option('_category_image'.$term_id);
}
编辑:get_wp_term_image($term_id)返回图片的url。
它工作正常,但我想调整返回图像的大小,因为我在显示所有分类类别的页面中使用它,并带有相对拇指。这意味着如果您上传一张大图片,您会得到该图片,并且页面会变得非常难以加载。我试图在我的页面循环中添加这个钩子但没有成功:
$term_id = $term->term_id;
if (function_exists('get_wp_term_image'))
{
$meta_image = get_wp_term_image($term_id);
//tried this
$term_image = wp_get_attachment_image_src($term_id, 'smalltax');
//and this
$image_id = attachment_url_to_postid($meta_image);
//no success
}
- 在第一种情况下,我假设
wp_get_attachment_image_src挂钩会考虑来自任何 id 的附件,但我错了。 注意。我没有图像 ID,我有image url和term_id - 在第二种情况下,我想用
attachment_url_to_postid钩子然后用其他一些调整大小 调整。
你能提供一个解决方案吗?甚至帮助修改插件本身。谢谢!
【问题讨论】:
标签: php wordpress image-processing attachment image-size