[英]get_the_post_thumbnail not displaying correctly in IE, but fine on FF and Chrome
此代碼中的縮略圖在FF和Chrome中正確顯示,但在IE中,它們是根據它們的比例顯示的。
我將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;
}
解決方案是使用width: auto;
作為圖像屬性之一。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.