Post by emreyaslan » Fri Aug 10, 2018 9:37 am

hey guys i have been 2 days surfing the forums to find a solution for my problem and tried everything about it but it jus't won't get fixed so as a last resort maybe someone can give me a direction to work to on solving my problem.
i got a CSV with 100000 products and the images of it are from external sites, so i tried to play with the image.php file, as stated on some of the topics but the images still didn't pop up on my site.

this is the code of my image.php from image/catalog/tool :

Code: Select all

<?php
class ModelToolImage extends Model {
	public function resize($filename, $width, $height) {
		if (!file_exists(DIR_IMAGE . $filename) || !is_file(DIR_IMAGE . $filename)) {
	return HTTP_IMAGE.$width.'x'.$height.'-'.$filename;
} 
		}

		$extension = http://($filename, PATHINFO_EXTENSION);

		$image_old = $filename;
		$image_new = 'http/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . (int)$width . 'x' . (int)$height . '.' . $extension;

		if (!is_file(DIR_IMAGE . $image_new) || (filectime(DIR_IMAGE . $image_old) > filectime(DIR_IMAGE . $image_new))) {
			list($width_orig, $height_orig, $image_type) = getimagesize(DIR_IMAGE . $image_old);
				 
			if (!in_array($image_type, array(IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF))) { 
				return DIR_IMAGE . $image_old;
			}
						
			$path = '';

			$directories = explode('/', http://($image_new));

			foreach ($directories as $directory) {
				$path = $path . '/' . $directory;

				if (!is_dir(DIR_IMAGE . $path)) {
					@mkdir(DIR_IMAGE . $path, 0777);
				}
			}

			if ($width_orig != $width || $height_orig != $height) {
				$image = new Image(DIR_IMAGE . $image_old);
				$image->resize($width, $height);
				$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 automatic changing space " " to +
		
		if ($this->request->server['HTTPS']) {
			return $this->config->get('config_ssl') . 'image/' . $image_new;
		} else {
			return $this->config->get('config_url') . 'image/' . $image_new;
		}
	}
}
am i missing out here on something that you guys actually could notice?
thanks in regardss

Newbie

Posts

Joined
Fri Aug 10, 2018 9:03 am

Post by straightlight » Sat Aug 11, 2018 12:19 am

As a new forum user, please read the forum rules. No OC version posted. Purpose of the modifications unprovided with the described issue.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: Bing [Bot], Semrush [Bot] and 162 guests