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;
}