2013-11-25 37 views
-2

我有點問題,將圖像尺寸添加到我的WordPress代碼網站的php代碼中。當我通過GTMetrix檢查頁面速度時,他們建議我特別添加圖像尺寸以增加頁面加載時間。將img尺寸屬性添加到php代碼中

下面的代碼行調用這些圖像:

<div class="postdate"> 
<img src="<?php bloginfo('template_url'); ?>/images/**date.png**" /> 
<? php the_time('F jS, Y') ?> 
<img src="<?php bloginfo('template_url'); ?>/images/**folder.png**" /> 
<?php the_category(', ') ?> 
<img src="<?php bloginfo('template_url'); ?>/images/**comments.png**" /> 
<?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?> 
<?php if (current_user_can('edit_post', $post->ID)) { ?> 
    <img src="<?php bloginfo('template_url'); ?>/images/**edit.png**" /> 
    <?php edit_post_link('Edit', '', ''); 
} ?> 
</div> 

我想能夠每個圖像(高亮)後添加的尺寸寬度= 16和高度= 16。

請幫忙。

問候,伊姆蘭。

+0

應用類到你的'img'標籤,並使用CSS來指定這些尺寸,已經讀這裏:http://www.w3schools.com/cssref/pr_dim_height.asp –

回答

0
<div class="postdate"> 
    <img width="16" height="16" src="<?php bloginfo('template_url'); ?>/images/**date.png**" /> 
    <? php the_time('F jS, Y') ?> 
    <img width="16" height="16" src="<?php bloginfo('template_url'); ?>/images/**folder.png**" /> 
    <?php the_category(', ') ?> 
    <img width="16" height="16" src="<?php bloginfo('template_url'); ?>/images/**comments.png**" /> 
    <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?> 
    <?php if (current_user_can('edit_post', $post->ID)) { ?> 
     <img width="16" height="16" src="<?php bloginfo('template_url'); ?>/images/**edit.png**" /> 
    <?php edit_post_link('Edit', '', ''); ?> 
</div> 
0

或者使用CSS?

<style type="text/css"> 
    .postdate img { 
     width: 16px; 
     height: 16px; 
    } 
</style>