filemtime(DIR_IMAGE . $image_new))) { list($width_orig, $height_orig, $image_type) = getimagesize(DIR_IMAGE . $image_old); if (!in_array($image_type, [IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF, IMAGETYPE_WEBP])) { return $this->config->get('config_url') . 'image/' . $image_old; } $path = ''; $directories = explode('/', dirname($image_new)); foreach ($directories as $directory) { if (!$path) { $path = $directory; } else { $path = $path . '/' . $directory; } if (!is_dir(DIR_IMAGE . $path)) { @mkdir(DIR_IMAGE . $path, 0777); } } if ($width_orig != $width || $height_orig != $height) { $image = new \Opencart\System\Library\Image(DIR_IMAGE . $image_old); $image->resize($width, $height, $default); $image->save(DIR_IMAGE . $image_new); } else { copy(DIR_IMAGE . $image_old, DIR_IMAGE . $image_new); } } $image_new = str_replace(' ', '%20', $image_new); // fix bug when attach image on email (gmail.com). it is automatically changing space from " " to + return $this->config->get('config_url') . 'image/' . $image_new; } }