WordPress 设置相册图集(galleries)默认的图片大小

时间:2019-08-29   阅读:452

默认情况下,WordPress 内置的相册图集(galleries)会使用完整尺寸(full)大小的图片,但是在某些情况下,也许我们需要使用其他尺寸。下面有一段很简单的代码可以让你设置相册图集(galleries)默认的图片大小,只需要添加到当前主题的 functions.php 即可:

1
2
3
4
/**
 * WordPress 设置相册图集(galleries)默认的图片大小
 * https://www.wpdaxue.com/set-the-default-image-size-in-wordpress-galleries.html
 */remove_shortcode('gallery');add_shortcode('gallery', 'custom_size_gallery');function custom_size_gallery($attr) {$attr['size'] = 'medium';return gallery_shortcode($attr);}

/** * WordPress 设置相册图集(galleries)默认的图片大小 * https://www.wpdaxue.com/set-the-default-image-size-in-wordpress-galleries.html */ remove_shortcode('gallery'); add_shortcode('gallery', 'custom_size_gallery'); function custom_size_gallery($attr) { $attr['size'] = 'medium'; return gallery_shortcode($attr); }

你只需要修改第 8 行的 medium 为你需要的尺寸即可。

上一篇:WordPress 站点集成 Google 自定义搜索引擎

下一篇:WordPress 生成文章预览链接给其他用户查看

网友评论