0

在我的 theme-functions.php 文件中,我有

add_image_size('ad-medium', $width = 250, $height = 250, true );

这决定了 Wordpress 创建“广告媒体”缩略图的大小。对此代码的任何更改都会立即确定网站上显示的内容。

所以如果我把 250 改成 100,宽度会减小到 100px。不幸的是,这存在三个问题:

  1. 这会改变广告媒体未来所有上传调整大小的尺寸,所以这是不可能的。
  2. 高度被忽略 - 我无法扭曲它 - 无论如何它都保持 1:1 的纵横比。
  3. 我不能写100%。百分号无法理解。

在上下文中,代码是:

    <?php
}


// activate theme support items
if (function_exists('add_theme_support')) { // added in 2.9

    // this theme uses post thumbnails
    add_theme_support('post-thumbnails', array('post', 'page'));
    set_post_thumbnail_size(100, 100); // normal post thumbnails

    // add default posts and comments RSS feed links to head
    add_theme_support( 'automatic-feed-links' );
}

// setup different image sizes
if ( function_exists( 'add_image_size' ) ) {
    add_image_size('blog-thumbnail', 150, 150); // blog post thumbnail size, box crop mode
    add_image_size('sidebar-thumbnail', 140, 140, true); // sidebar blog thumbnail size, box crop mode

    // create special sizes for the ads
    add_image_size('ad-thumb', 75, 75, true); 
    add_image_size('ad-small', 100, 100, true);
    add_image_size('ad-medium', $width = 250, $height = 250, true );
    //add_image_size('ad-large', 500, 500); 
}

// Set the content width based on the theme's design and stylesheet.
// Used to set the width of images and content. Should be equal to the width the theme
// is designed for, generally via the style.css stylesheet.
if (!isset($content_width))
    $content_width = 500;


// This theme supports native menu options, and uses wp_nav_menu() in one location for top navigation.
function appthemes_register_menus() {
    register_nav_menus(array(
        'primary' => __( 'Primary Navigation', 'appthemes' ),
        'secondary' => __( 'Footer Navigation', 'appthemes' ),
        'theme_dashboard' => __( 'Theme Dashboard', 'appthemes' )
    ));
}
add_action( 'init', 'appthemes_register_menus' );

//ajax header javascript builder for child categories AJAX dropdown builder
function cp_ajax_addnew_js_header() {
    global $app_abbr;
    $parentPosting = get_option($app_abbr.'_ad_parent_posting');
    // Define custom JavaScript function
?>

如何单独保留缩略图调整大小功能并添加另一行代码将其调整为 100% 宽度 100% 高度?目前,除了顽固的缩略图,整个页面都在调整大小。

请让我知道该怎么做。

谢谢。

4

1 回答 1

0

请参阅:http ://codex.wordpress.org/Post_Thumbnails :帖子缩略图被赋予一个类“wp-post-image”。它们还根据显示的缩略图的大小获得一个类。您可以使用这些 CSS 选择器设置输出样式。

所以你可以添加到你的主题 css 文件中:

 #content img.ad-medium {height:100%; Width:100%;}
于 2013-05-19T08:52:52.963 回答