这是我的配置文件。我已经更改了图像子域,但图片无法加载。
<?php
// HTTP
define('HTTP_SERVER', 'http://www.Yek.com/');
define('HTTP_IMAGE', 'http://img.Yek.com/');
// HTTPS
define('HTTPS_SERVER', 'https://www.Yek.com/');
define('HTTPS_IMAGE', 'https://img.Yek.com/');
// DIR
define('DIR_APPLICATION', '/home/Yek/public_html/catalog/');
define('DIR_SYSTEM', '/home/Yek/public_html/system/');
define('DIR_DATABASE', '/home/Yek/public_html/system/database/');
define('DIR_LANGUAGE', '/home/Yek/public_html/catalog/language/');
define('DIR_TEMPLATE', '/home/Yek/public_html/catalog/view/theme/');
define('DIR_CONFIG', '/home/Yek/public_html/system/config/');
//define('DIR_IMAGE', '/home/Yek/public_html/image/');//defult For Images/catlog on main host
define('DIR_IMAGE', '/home/Yek/public_html/img/image/'); // image/catalog in download host
define('DIR_CACHE', '/home/Yek/public_html/system/cache/');
define('DIR_DOWNLOAD', '/home/Yek/public_html/system/download/');
define('DIR_LOGS', '/home/Yek/public_html/system/logs/');
define('DIR_UPLOAD', '/home/Yek/public_html/system/upload/');
define('DIR_MODIFICATION', '/home/Yek/public_html/system/modification/');
// DB
....
?>
这是我的image.php。为我编辑? 不知道在哪里编辑这段代码............................................ .................................................. .................................................. .................................................. .................................................. ....................
<?php
class ModelToolImage extends Model {
public function resize($filename, $width, $height) {
if (!is_file(DIR_IMAGE . $filename)) {
return;
}
$extension = pathinfo($filename, PATHINFO_EXTENSION);
$old_image = $filename;
$new_image = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
if (!is_file(DIR_IMAGE . $new_image) || (filectime(DIR_IMAGE . $old_image) > filectime(DIR_IMAGE . $new_image))) {
$path = '';
$directories = explode('/', dirname(str_replace('../', '', $new_image)));
foreach ($directories as $directory) {
$path = $path . '/' . $directory;
if (!is_dir(DIR_IMAGE . $path)) {
@mkdir(DIR_IMAGE . $path, 0777);
}
}
list($width_orig, $height_orig) = getimagesize(DIR_IMAGE . $old_image);
if ($width_orig != $width || $height_orig != $height) {
$image = new Image(DIR_IMAGE . $old_image);
$image->resize($width, $height);
$image->save(DIR_IMAGE . $new_image);
} else {
copy(DIR_IMAGE . $old_image, DIR_IMAGE . $new_image);
}
}
if ($this->request->server['HTTPS']) {
return $this->config->get('config_ssl') . 'image/' . $new_image;
} else {
return $this->config->get('config_url') . 'image/' . $new_image;
}
}
}
答案 0 :(得分:2)
将您的子域指向您的图片目录
在托管控制面板中添加子域时,必须将其指向图像目录。如果您无权访问控制面板,则必须询问管理员。
答案 1 :(得分:1)
/catalog/model/tool/image.php 发现$ this-&gt; config-&gt; get(&#39; config_url&#39;) 并改变
protected function getImageUrl($new_image) {
$parts = explode('/', $new_image);
$new_url = implode('/', array_map('rawurlencode', $parts));
if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
return $this->config->get('config_ssl') . 'image/' . $new_url;
}
else {
return $this->config->get('config_url') . 'image/' . $new_url;
}
}