2017-04-06 50 views
1

此代码中的缩略图在FF和Chrome中正确显示,但在IE中,它们正根据它们的比例显示。get_the_post_thumbnail在IE中无法正确显示,但在FF和Chrome上没有问题

我有50px设置为长度和高度,所有缩略图都是FF和Chrome中的完美正方形。然而,在IE中,因为它们正在根据某个比例重新调整大小,所以某些缩略图显得很瘦,而其他缩略图则以50x50的尺寸正确显示。但是,所有的缩略图仍然在50x50范围内,只是有些缩略图比其他缩略图更小。

function posts_in_cat($atts) { 
$atts = shortcode_atts(array(
    'cat' => '', 
), $atts); 

if (empty($atts['cat'])) { 
    // If category provided, exit early 
    return; 
} 

$args = array(
    'category' => $atts['cat'], 
    // Disable pagination 
    'posts_per_page' => -1 
); 

$posts_list = get_posts($args); 

if (empty($posts_list)) { 
    // If no posts, exit early 
    return; 
} 

$opening_tag = '<ul style="list-style-type:none; padding-left:2px; display:block; clear:both;">'; 
$closing_tag = '</ul>'; 
$post_content = ''; 

foreach ($posts_list as $post_cat) { 
    $post_content .= '<li class="highlightli" style="line-height:1.2em; margin-bottom:10px; display: flex !important; align-items: center !important;">' . get_the_post_thumbnail($post_cat->ID, array(50,50), array('class' => 'imgspecialalignleft')) . '<a href="' . esc_url(get_permalink($post_cat->ID)) . '">' . esc_html(get_the_title($post_cat->ID)) . '</a></li>'; 
} 

return $opening_tag . $post_content . $closing_tag; 
} 

回答

0

解决方法是使用width: auto;作为其中一个图像属性。

相关问题