【发布时间】:2015-04-18 11:14:23
【问题描述】:
我这里有一个搜索页面:
http://www.journeyfilm.com/?s=screening
显示带有特色图片的帖子。问题是图像与它应该适合的区域的比例不同。如您所见,这使得图像看起来非常小。我希望它要么只拉缩略图,要么通过css适应宽度并隐藏任何额外的高度。它似乎应该拉缩略图,如果没有缩略图,则显示默认图像。
这是我的 content.php html
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php if ( 'post' == get_post_type() || 'video' == get_post_type()) : ?>
<a href="<?php the_permalink(); ?>" rel="bookmark">
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail( array(300, 165) );
} else {
?>
<img src="<?php echo esc_url( home_url( '/' ) ); ?>/wp-content/uploads/2014/10/ftr-image-journeyfilm.png" title="Journey Film Logo" alt="Journey Film Logo"/>
<?php } ?>
<h1 class="entry-title-search"><?php the_title(); ?></h1>
<div class="entry-meta-search">
<?php undiscovered_posted_on(); ?>
</div>
</a>
<?php elseif ( 'page' == get_post_type() ) : ?>
<a href="<?php the_permalink(); ?>" rel="bookmark">
<h1 class="entry-title-search"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
<?php if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail( array(300, 165) );
} else {
?>
<img src="<?php echo esc_url( home_url( '/' ) ); ?>/wp-content/uploads/2014/10/ftr-image-journeyfilm.png" title="Journey Film Logo" alt="Journey Film Logo"/>
<?php } ?>
<div class="entry-meta-search">
<span class="posted-on">Standard Page</span>
</div>
</a>
<?php endif; ?>
</header>
</article>
还有我的 Search.php HTML:
<?php get_header(); ?>
<section id="primary" class="content-area search "><!--.w-sidebar-->
<main id="main" class="site-main" role="main">
<h1 class="search-title">Search Results: <?php echo the_search_query()?></h1>
<?php
if(isset($_GET['post_type'])) {
$type = $_GET['post_type'];
$args = array( 'post_type' => $type );
$args = array_merge( $args, $wp_query->query );
query_posts( $args );
}
?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'search' ); ?>
<?php endwhile; ?>
<div class="clear"><div><?php undiscovered_paging_nav(); ?>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
</main>
</section><!-- .primary -search.php -->
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
CSS:
a img {
border: 0 none;
}
img {
height: auto;
max-width: 100%;
}
img {
vertical-align: middle;
}
任何建议将不胜感激。谢谢!
【问题讨论】:
标签: wordpress search thumbnails