Post by tjonnyc » Sat Jun 25, 2011 6:35 am

I would like to switch image delivery from the main server to a subdomain (ex: images.mysite.com).

I changed the path in config.php and admin/config.php, but it made no difference, except breaking the thumbnails in admin.

What step(s) am I missing in order to shift all the image resources to a subdomain?

Or if anyone has a step-by-step guide, it would be much appreciated.

I'm on a great host with every option under the sun, so I can make any CNAME, subdomain, actual domain, etc, changes.

Active Member

Posts

Joined
Tue Dec 21, 2010 5:05 am

Post by rph » Sat Jun 25, 2011 2:10 pm

What version are you using? In 1.4.x I replaced:

/index.php

Code: Select all

define('HTTP_IMAGE', HTTP_SERVER . 'image/');
with

Code: Select all

define('HTTP_IMAGE', str_replace('http://', 'http://image.', HTTP_SERVER));
Then configured the subdomain on the host.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by tjonnyc » Thu Jul 28, 2011 1:51 am

Ryan:

Thank you for your reply!

I'm using 1.4.9.5.

Will try your solution & report back.

Active Member

Posts

Joined
Tue Dec 21, 2010 5:05 am

Post by dony_b » Sun Feb 19, 2012 2:56 am

rph wrote:What version are you using? In 1.4.x I replaced:

/index.php

Code: Select all

define('HTTP_IMAGE', HTTP_SERVER . 'image/');
with

Code: Select all

define('HTTP_IMAGE', str_replace('http://', 'http://image.', HTTP_SERVER));
Then configured the subdomain on the host.
How can I implement this in v1.5. Thanks

User avatar
Active Member

Posts

Joined
Wed Aug 18, 2010 9:56 pm
Location - Boston, MA

Post by rph » Mon Feb 20, 2012 5:05 am

You should be able to just change

Code: Select all

define('HTTP_IMAGE', 'http://yourstore.com/'); 
to

Code: Select all

define('HTTP_IMAGE', 'http://image.yourstore.com/'); 
where "youstore.com" is your domain and "image" is the appropriate sub-domain (the sub-domain should point to OpenCart's regular image dir).

I believe that browsers and net standards have shifted in the last several months so that such setups are no longer considered CDNs though.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by tim_s » Mon Feb 20, 2012 8:08 pm

I don't know that it's considered a CDN, however, it does speed up page load times. Subdomains are treated like separate domains, so they will load the images as if it's external. Here's a tutorial on it:

http://www.inmotionhosting.com/support/ ... n-opencart

Tim S

OpenCart Tutorials

vQmod Extension to remove "Powered By" in Footer


User avatar
New member

Posts

Joined
Thu Jan 19, 2012 1:40 am

Post by fido » Mon Feb 20, 2012 8:34 pm

I understand that still do not display img?

Oferujemy kartony klapowe w dobrej cenie. Opakowania tekturowe dla ciebie.


Newbie

Posts

Joined
Mon Feb 20, 2012 8:22 pm


Post by rph » Mon Feb 20, 2012 8:59 pm

tim_s wrote:I don't know that it's considered a CDN, however, it does speed up page load times. Subdomains are treated like separate domains, so they will load the images as if it's external. Here's a tutorial on it:

http://www.inmotionhosting.com/support/ ... n-opencart
I'm perfectly aware of that. If you look at Google Page Speed or WebPageTest.org you'll see they no longer stress this like they once did as the way modern browsers work has changed and there now exists more advanced methods of parallelization.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by dony_b » Mon Feb 20, 2012 11:29 pm

rph wrote:You should be able to just change

Code: Select all

define('HTTP_IMAGE', 'http://yourstore.com/'); 
to

Code: Select all

define('HTTP_IMAGE', 'http://image.yourstore.com/'); 
where "youstore.com" is your domain and "image" is the appropriate sub-domain (the sub-domain should point to OpenCart's regular image dir).
I have done this already but this only works if the subdomain is in the same server as the core files and DB. However if the subdomain is hosted somewhere else does not work. I wonder what needs to be changed for this to work.

User avatar
Active Member

Posts

Joined
Wed Aug 18, 2010 9:56 pm
Location - Boston, MA

Post by rph » Tue Feb 21, 2012 5:52 am

Search the forum. I believe someone posted instructions on how to modify .htaccess to use external images. You'll have to create all the different image sizes manually since OpenCart isn't designed for doing this.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by dony_b » Tue Feb 21, 2012 10:18 am

rph wrote:Search the forum. I believe someone posted instructions on how to modify .htaccess to use external images. You'll have to create all the different image sizes manually since OpenCart isn't designed for doing this.
I have searched but no clear answers found so far. Whats the post title so I can find it ?

I dont think you can re-size the image size with htaccess I think its more like to be done on image.php

User avatar
Active Member

Posts

Joined
Wed Aug 18, 2010 9:56 pm
Location - Boston, MA

Post by rph » Tue Feb 21, 2012 10:26 am

Don't remember what it was called. You'll just have to try searching under different terms.
I dont think you can re-size the image size with htaccess I think its more like to be done on image.php
Am I talking to myself here? Like I said, OpenCart cannot handle doing this. You will have to manually resize, rename, and upload all your image files. The only thing that can be easily done is the redirect.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by dony_b » Tue Feb 21, 2012 11:32 am

This file basically controls the image resize so I wonder if I modify it here.

catalog/model/tool/image.php

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;
		} 
		
		$info = pathinfo($filename);
		$extension = $info['extension'];
		
		$old_image = $filename;
		$new_image = 'cache/' . substr($filename, 0, strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
		
		if (!file_exists(DIR_IMAGE . $new_image) || (filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image))) {
			$path = '';
			
			$directories = explode('/', dirname(str_replace('../', '', $new_image)));
			
			foreach ($directories as $directory) {
				$path = $path . '/' . $directory;
				
				if (!file_exists(DIR_IMAGE . $path)) {
					@mkdir(DIR_IMAGE . $path, 0777);
				}		
			}
			
			$image = new Image(DIR_IMAGE . $old_image);
			$image->resize($width, $height);
			$image->save(DIR_IMAGE . $new_image);
		}
		
		if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
			return HTTPS_IMAGE . $new_image;
		} else {
			return HTTP_IMAGE . $new_image;
		}	
	}
}
?>

User avatar
Active Member

Posts

Joined
Wed Aug 18, 2010 9:56 pm
Location - Boston, MA

Post by rph » Tue Feb 21, 2012 2:21 pm

Yes, I know what it does. I've been working with OpenCart since the 0.x days. And no, messing around with that is not going to get OpenCart interfacing and uploading to a third-party image server. You'll have to hire a developer because this is not something simple to do.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by Qphoria » Wed Feb 22, 2012 1:02 pm

I have this tutorial:
http://forum.opencart.com/viewtopic.php?f=138&t=40573

But although it is recommended to use a subdomain for images.. it isn't considered a "CDN" since its on the same domain. Due to the way images are auto resized locally, external hosting doesn't really work at this time.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by dony_b » Thu Feb 23, 2012 5:49 am

Qphoria wrote:I have this tutorial:
http://forum.opencart.com/viewtopic.php?f=138&t=40573

But although it is recommended to use a subdomain for images.. it isn't considered a "CDN" since its on the same domain. Due to the way images are auto resized locally, external hosting doesn't really work at this time.
I've done that already but like you said it cant be done done unless its on the same local server.

I have all my css and js files in a cdn but its funny because the styles and javascripts load before the images do so it creates some sort of latency.

User avatar
Active Member

Posts

Joined
Wed Aug 18, 2010 9:56 pm
Location - Boston, MA

Post by justinv » Tue May 15, 2012 7:49 am

This free module http://opencart.hostjars.com/opencart-cdn with CloudCache CDN service is the easiest way I've seen to get your site on a CDN.

Documentation: OpenCart User Guide
Mods: Total Import PRO | CSV Import PRO | Ecom Tracking | Any Feed | Autosuggest | OpenCart CDN
Image


Active Member

Posts

Joined
Tue Oct 12, 2010 1:24 pm

Post by seanster » Tue Jul 17, 2012 12:08 am

Here is a plugin that came out in march. I tried editing the Cloudcache CDN one and its to much of a pane.
http://www.opencart.com/index.php?route ... e=bildukas

Newbie

Posts

Joined
Thu Mar 08, 2012 7:09 am
Who is online

Users browsing this forum: No registered users and 21 guests