我有 MySQL 表中图像位置的 url。我如何检索该图像的高度和宽度并将其插入到下面的 img 标签中?
<img id="profileImg" alt="" height="96" width="87" src="<?=base_url().$row1->imgURI?>" />
最佳答案
与 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 访问该文件,那就太好了。但我会把这个留到最后。
关于php - 从 MySQL 数据库检索图像的高度和宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11902681/