dongtun4268 2017-04-06 19:26
浏览 58
已采纳

get_the_post_thumbnail在IE中无法正确显示,但在FF和Chrome上却没问题

The thumbnails in this code are displaying correctly in FF and Chrome but in IE they are being displayed based on their ratio.

I have 50px set as the length and height and all the thumbnails are perfect squares in FF and Chrome. In IE however, because they are being re-sized based on some ratio, some thumbnails are appearing skinny while others are displaying correctly with the 50x50 dimensions. However, all the thumbnails are still within the 50x50 boundary, just that some are skinnier than the others.

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;
}
  • 写回答

1条回答 默认 最新

  • douwendu2460 2017-04-07 02:22
    关注

    The solution was to use width: auto; as one of the image properties.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥66 比特币地址如何生成taproot地址
  • ¥20 数学建模数学建模需要
  • ¥15 关于#lua#的问题,请各位专家解答!
  • ¥15 什么设备可以研究OFDM的60GHz毫米波信道模型
  • ¥15 不知道是该怎么引用多个函数片段
  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决