2016-04-11 14 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

<img>heightwidth属性を追加します。以下のコードを確認してください。

<?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

あなたはPHPの幅/高さを取得するために取得するためにtryyingていますか?

もしそうなら、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 } ?> 
関連する問題