将图像显示为缩略图的问题 [英] problem displaying images as thumbnails
问题描述
您好
我在将图像显示为表格中的缩略图时遇到问题。我的代码
用于从原始图像生成新的宽度和高度如下
****************** ********************************
if($ ImagePath){
// $ Image = WEB_ROOT。 ''images / PupilTester /''。 $ ImagePath;
$ Image =''images / PupilTester /''。 $ ImagePath;
}其他{
$ Image =''images / PupilTester / nopicture.bmp'';
}
$ size = getimagesize($ image);
$ height = $ size [1];
$ width = $ size [0] ;
if($ height> 150)
{
$ height = 150;
$ percent = ($ size [1] / $ height);
$ width =($ size [0] / $ percent);
}
否则如果($ width> 150)
{
$ width = 150;
$ percent =($ size [0] / $宽度);
$ height =($ size [1] / $ percent);
}
// echo"< img src\"图像/路径/ image.jpg\" height = \" $ height\"
width = \" $ width\" />" ;;
************************************ ************** ************
并在我的表格中显示我的缩略图/>
**************************************** ********** ************
< td rowspan =" 5" valign =" top">< div align =" left">< img src =<?php echo $ Image;
?> width =<?php echo" $ width"?> height =<?php echo" $ height"?>>
< / div>< / td>
< / tr>
******************************************** ****** **************
但是图像根本没有显示。桌子的单元格是空白的。
但如果我使用
****************** ***************************
< td>< img src =<?php echo $图片; ?>>< / td>
< / tr>
******************* ************************
图像正常显示完整尺寸。任何人都可以看到我出错的地方
Thaks
Ian
Hello
Im having problems displaying my images as thumbnails in a table. My code
for producing the new width and height from the original image is as follows
**************************************************
if ($ImagePath) {
//$Image = WEB_ROOT . ''images/PupilTester/'' . $ImagePath;
$Image = ''images/PupilTester/'' . $ImagePath;
} else {
$Image =''images/PupilTester/nopicture.bmp'';
}
$size = getimagesize($image);
$height = $size[1];
$width = $size[0];
if ($height > 150)
{
$height = 150;
$percent = ($size[1] / $height);
$width = ($size[0] / $percent);
}
else if ($width > 150)
{
$width = 150;
$percent = ($size[0] / $width);
$height = ($size[1] / $percent);
}
//echo "<img src\"image/path/image.jpg\" height=\"$height\"
width=\"$width\" />";
************************************************** ************
and in my table to display the thumbnail I have
************************************************** ************
<td rowspan="5" valign="top"><div align="left"><img src=<?php echo $Image;
?> width= <?php echo "$width"?> height= <?php echo "$height"?>>
</div></td>
</tr>
************************************************** **************
However the images are not showing at all. The cells of the table are blank.
But if I use
*********************************************
<td><img src=<?php echo $Image; ?>></td>
</tr>
*******************************************
The images show full size as normal. Can anyone see where Ive gone wrong
Thaks
Ian
推荐答案
ImagePath){
//
ImagePath) {
//
Image = WEB_ROOT。 ''images / PupilTester /''。
Image = WEB_ROOT . ''images/PupilTester/'' .
ImagePath;
ImagePath;
这篇关于将图像显示为缩略图的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!