如何在变量中设置图像样式? [关闭]

I have an image being pulled out of a forum (avatars), but every time i grab them, they are not fitting my div, no matter what i do, i'm wondering how can i fit that image inside my div?

Here's the line i'm talking about:

<div id="image">'.$ipbwi->member->photo($friend['friends_friend_id']).'</div>

And here's a whole foreach:

<?php
$friends = $ipbwi->member->friendsList(false,true);
foreach($friends as $friend){
echo '
<div class="friend">
<div id="image">'.$ipbwi->member->photo($friend['friends_friend_id']).'</div>
<div class="username">'.$ipbwi->member->id2displayname($friend['friends_friend_id']).'</div>
</div>
';
}
?>

I'm using ipbwi to pull data from ipb forum and i would like to scale all the images to (example) 40x40px.

Edit:

here's the css i'm using for img on div: #friend #image img{width: 40px; height: 40px;}

Thanks in advance!

try adding the style rule

.friend img { max-width:100px; max-height:100px }

I have done this in the past.

.img-resize {
  width: 200px;
  height : auto;
}

.img-resize {
  width: auto;
  height : 300px;
}

Create a css class img-resize and give it the width and height you desire. This will keep the aspect ration. Use like: <img src="http://example.com/12.jpg" class="img-resize" /> Then you can just replace the scr with value from the db.

Use this CSS to resize your images:

img {
  max-width: 40px;
  max-height: 40px;
}

Also, keep in mind that this will aplly to every img tag on your page, so to be more specific you could do something like:

.friend img {
  max-width: 40px;
  max-height: 40px;
}

This will only re-size images that are inside of a div tag with the class "friend"