使中大图像可用于插入POST

时间:2018-01-05 作者:FreshClicks

我们的帖子最大宽度为768,因此作者首选使用中大图片。我假设medium\\u large isnpart of core,这将包括在内,但我看不到激活该选项的简单方法。

这可以作为我们函数中的一个新挂钩激活吗。php?

2 个回复
最合适的回答,由SO网友:FreshClicks 整理而成

因为我使用的是WP已经生成的大小,所以我只需要添加:

add_filter( \'image_size_names_choose\', \'fresh_custom_sizes\' );
function fresh_custom_sizes( $sizes ) {
   return array_merge( $sizes, array(
      \'medium_large\' => __( \'Medium Large\' ),
   ) );
}

SO网友:jas

请通过link for details 我希望这可能有助于增加您的自定义首选尺寸。

// Make sure featured images are enabled
add_theme_support( \'post-thumbnails\' );

// Add featured image sizes
add_image_size( \'featured-large\', 640, 294, true ); // width, height, crop
add_image_size( \'featured-small\', 320, 147, true );

// Add other useful image sizes for use through Add Media modal
add_image_size( \'medium-width\', 480 );
add_image_size( \'medium-height\', 9999, 480 );
add_image_size( \'medium-something\', 480, 480 );

// Register the three useful image sizes for use in Add Media modal
add_filter( \'image_size_names_choose\', \'wpshout_custom_sizes\' );
function wpshout_custom_sizes( $sizes ) {
    return array_merge( $sizes, array(
        \'medium-width\' => __( \'Medium Width\' ),
        \'medium-height\' => __( \'Medium Height\' ),
        \'medium-something\' => __( \'Medium Something\' ),
    ) );
}

结束

相关推荐

Get images by category

我目前获取滑块图像的方法是使用以下工作正常的代码:$args = array( \'post_type\' => \'attachment\', \'sort_order\' => \'ASC\', \'sort_column\' => \'menu_order\', ); $attachments = get_posts($args); if ($attachments) { $