怎样在wordpress中自由设置文章缩略图大小
在定做wordpress主题时,经常在代码中就规定了文章缩略图的尺寸,用户使用时,无论上传多大的图片,都会生成规定尺寸的缩略图,而现在有种办法可以让用户自己在编辑文章时设置文章缩略图尺寸了,方法相当的简单,而实现的效果却非常实用。
打开主题的函数文件functions.php,加入以下代码:
if ( function_exists( 'add_theme_support' ) ) { add_theme_support( '<a rel="noopener noreferrer nofollow" href="http://www.chhua.com/web-notetag/post" rel="noopener noreferrer nofollow" target="_blank" title="post">post</a>-thumbnails' ); set_post_thumbnail_size( 150, 150, true ); add_image_size( 'my-custom-size', 300, 300, true ); }
非常不错,set_post_thumbnail_size 是中的150就是文章图标的大小。