2016-04-11 76 views
0

我想弄清楚在哪裏指定facebook.png的圖像大小,即24x24。指定由PHP文件調用的圖像寬度和高度

下面是代碼,但我不確定如何指定大小。我知道如何在HTML中做到這一點,但不是在PHP中。

<?php if (get_option('solostream_facebook_url')) { ?> 
    <a title="<?php echo stripslashes(get_option('solostream_facebook_link_text')); ?>" rel="external" href="http://www.facebook.com/<?php echo stripslashes(get_option('solostream_facebook_url')); ?>"><img class="facebook-sub" src="<?php bloginfo('template_directory'); ?>/images/facebook.png" alt="<?php echo stripslashes(get_option('solostream_facebook_link_text')); ?>" align="top" /></a> 
<?php } ?> 
+1

+0

請清楚解釋你的問題,你究竟想要什麼? –

回答

0

添加heightwidth屬性<img>。檢查下面的代碼。

<?php if (get_option('solostream_facebook_url')) { ?> 
 
<a title="<?php echo stripslashes(get_option('solostream_facebook_link_text')); ?>" rel="external" href="http://www.facebook.com/<?php echo stripslashes(get_option('solostream_facebook_url')); ?>"><img class="facebook-sub" src="<?php bloginfo('template_directory'); ?>/images/facebook.png" alt="<?php echo stripslashes(get_option('solostream_facebook_link_text')); ?>" align="top" height="24" width="24"/></a> 
 
<?php } ?>

0

你tryying讓PHP檢索寬度/高度?

如果是,則getimagesize()函數將做到這一點:

<?php if (get_option('solostream_facebook_url')) { ?> 
    list($width, $height, $type, $dims) = getimagesize("bloginfo('template_directory')/images/facebook.png"); 
    <a title="<?php echo stripslashes(get_option('solostream_facebook_link_text')); ?>" rel="external" href="http://www.facebook.com/<?php echo stripslashes(get_option('solostream_facebook_url')); ?>"><img $dims class="facebook-sub" src="<?php bloginfo('template_directory'); ?>/images/facebook.png" alt="<?php echo stripslashes(get_option('solostream_facebook_link_text')); ?>" align="top" /></a> 
<?php } ?>