html - Adding img attributes with php -


this works:

<?php       if($user->image > 0)      {           $imgsrc = "/uploads/".$user->image;           echo "your current image:" . "<br>";           echo "<img src= $imgsrc >";      } 

i need add height , width attributes $imgsrc have been unsuccessful far.

the image showing @ original dimensions , want change this.

ok transpires want change size of image original

echo "<img src='$imgsrc' style='width: 100px; height:100px;' />"; 

and maybe want maintain proportions

echo "<img src='$imgsrc' style='width: 100px; height:auto;' />"; 

if looking add exact size image using php this

if($user->image > 0)  {       $imgsrc = "/uploads/".$user->image;       list($width, $height) = getimagesize($imgsrc);       $style = 'width: ' . $width . 'px; height: ' . $height . 'px;';       echo 'your current image: <br />';       echo '<img src="' . $imgsrc . '" style="' . $style . '" alt="user image" />';  } 

Comments