解决ECSHOP缩略图截图方式 等比大小截图不留空白

2016-09-02 16:28 来源:www.chinab4c.com 作者:ecshop专家

ECSHOP唯一有一个小问题就是缩略图,默认是175宽度和高度的,客户要求宽一点,矮一点,所以我就从CSS里调整,但是有一个问题出现。因为后来即便可以设置缩略图大小,但截图之后是按照比例的。 如果原始图片不是工整的比例,那ECSHOP缩略图就有留空白问题,不能饱满的在首页和列表页面展示。于是寻找各种解决方法,如下。 打开includes/cls_image.php文件中(210行位置),找到如下代码: if ($org_info[0] / $thumb_width > $org_info[1] / $thumb_height) { $lessen_width = $thumb_width; $lessen_height = $thumb_width / $scale_org; } else { /* 原始图片比较高,则以高度为准 */ $lessen_width = $thumb_height * $scale_org; $lessen_height = $thumb_height; } 修改成: if ($org_info[0] / $thumb_width > $org_info[1] / $thumb_height) { $lessen_width = $thumb_height * $scale_org; $lessen_height = $thumb_height; } else { /* 原始图片比较高,则以高度为准 */ $lessen_width = $thumb_width; $lessen_height = $thumb_width / $scale_org; } 这样我们根据后台设置的图片比例大小就可以自动的饱满的完成ECSHOP缩略图效果。