我希望你做得很好,请打开此链接https://www.pixelstalk.net/winter-backgrounds/winter-background-for-desktop/
和屏幕截图链接在这里http://myprintscreen.com/s/p0bp/49cbf6d290
如何添加此选项以在我的WordPress单帖中显示此高度 宽度和图像大小?
谢谢
高度&宽度:
尝试以下内容。首先,将此代码添加到模板:
$image_data = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "full" );
$image_data
现在将返回包含URL,宽度和高度(功能参考)的数组。获得宽度&高度,您可能会这样做:
$image_width = $image_data[1];
$image_height = $image_data[2];
在您的特定示例中,将上面的两个代码添加到模板中后,您可能会这样做:
echo '<label class="dimension"> '.$image_width.' x '.$image_height.'</label>';
大小:
$image_size = size_format(filesize( get_attached_file( get_post_thumbnail_id( $post->ID ), "full" ) ));
在模板中,这样添加:
echo '<label class="data_size"><strong>Image size: </strong>'.$image_size.'</label>';