2012-08-10 65 views

回答

0

如果没有实际的widthheight存储在数据库中,你可以使用getimagesize()

<?php 
    $image = base_url().$row1->imgURI; 
    $size = getimagesize($image); 
?> 
<img id="profileImg" alt="" height="<?=$size[1];?>" width="<?=$size[0];?>" src="<?=$image;?>" /> 
+0

感谢的人。你的代码给我错误btw – 2012-08-10 13:40:26

+0

@Dainis Abols编辑。 .. – 2012-08-10 13:43:47

0

这是使用getimagesize功能最简单的检索:

list($width, $height, $type, $attr) = getimagesize (base_url() . $row1->imgURI); 
<img id="profileImg" alt="" <?=$attr?> src="<?=base_url().$row1->imgURI?>" /> 
2

随着http://php.net/manual/en/function.getimagesize.php

<?php 
list($width, $height, $type, $attr) = getimagesize(base_url() . $row1->imgURI); 
?> 
<img id="profileImg" alt="" height="<?=$height?>" width="<?=$width?>" src="<?=base_url().$row1->imgURI?>" /> 

此外它会很好,如果你可以派生图像文件的本地路径,以避免必须通过其URL访问文件。但我会留下来的。

+0

甜。谢啦。也有可能减少一个百分比的大小? – 2012-08-10 13:38:56

+0

'height =“<?= $ height * 0.9?>”width =“<?= $ width * 0.9?>”'for 90% – Peon 2012-08-10 13:41:03

+0

http://stackoverflow.com/questions/8819524/a-very-good -php图像 - 调整 - 脚本的建议 – 2012-08-10 13:46:08

相关问题