|
|
|
|
@ -116,19 +116,21 @@ class html_optimize_lib
|
|
|
|
|
//图片已经设置了尺寸的不再修改
|
|
|
|
|
if (empty($image->width) && (strpos($img_src, '//data.') !== false || strpos($img_src, '//images.') !== false)) {//以data或者images开头的域名才能获取尺寸
|
|
|
|
|
$img_src_urls = parse_url(trim($img_src));
|
|
|
|
|
$request_size[$img_src_urls['host']][] = $img_src_urls['path'];
|
|
|
|
|
$file_path = '';
|
|
|
|
|
if (strpos($img_src, '//data.') !== false) {
|
|
|
|
|
$file_path = $dataPath . $img_src_urls['path'];
|
|
|
|
|
}
|
|
|
|
|
if (strpos($img_src, '//images.') !== false) {
|
|
|
|
|
$file_path = $imagesPath . $img_src_urls['path'];
|
|
|
|
|
}
|
|
|
|
|
if (is_file($file_path)) {
|
|
|
|
|
$properties = getimagesize($file_path);//获取图片属性,读取失败返回false
|
|
|
|
|
if ($properties && !empty($properties[0]) && !empty($properties[1])) {
|
|
|
|
|
$image->width = $properties[0];
|
|
|
|
|
$image->height = $properties[1];
|
|
|
|
|
if ($img_src_urls){ //判断图片是否存在,不然会出错,无法静态化。20250403 zp
|
|
|
|
|
$request_size[$img_src_urls['host']][] = $img_src_urls['path'];
|
|
|
|
|
$file_path = '';
|
|
|
|
|
if (strpos($img_src, '//data.') !== false) {
|
|
|
|
|
$file_path = $dataPath . $img_src_urls['path'];
|
|
|
|
|
}
|
|
|
|
|
if (strpos($img_src, '//images.') !== false) {
|
|
|
|
|
$file_path = $imagesPath . $img_src_urls['path'];
|
|
|
|
|
}
|
|
|
|
|
if (is_file($file_path)) {
|
|
|
|
|
$properties = getimagesize($file_path);//获取图片属性,读取失败返回false
|
|
|
|
|
if ($properties && !empty($properties[0]) && !empty($properties[1])) {
|
|
|
|
|
$image->width = $properties[0];
|
|
|
|
|
$image->height = $properties[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|