Post by salam110 » Tue Aug 11, 2009 2:16 am

Hi;
When u click on a product; Opencart create various image from original image (120*120, 150*150 , 500*500 and ...)
With "if" u can check this image has created or not created.
Without "if",by click on a image of product, server has a process, and if u have many visitor then server printed "server is busy".
How can solve this problem, I cant find the relative code.
??? :o ;D ....

Newbie

Posts

Joined
Tue Aug 11, 2009 1:56 am

Post by Qphoria » Tue Aug 11, 2009 2:20 am

I don't really understand what you mean. Are you saying you want to "pre-create" all possible sizes so that you don't have to do it later?

The image resize helper is here:
system/helper/image.php

that is where the cache image is created. You could probably do some loop there.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by salam110 » Tue Aug 11, 2009 2:27 am

Qphoria wrote: Are you saying you want to "pre-create" all possible sizes so that you don't have to do it later?
yes. I want it. by first click on each image of product create all possible sizes is needed. then on later process check this(=Is there all possible sizes in cache folder or Not? )
this action cause server not busy. 8)
Why in each process all possible sizes is creating?

Newbie

Posts

Joined
Tue Aug 11, 2009 1:56 am

Post by Qphoria » Tue Aug 11, 2009 2:36 am

The way it currently works is if an image for the required size exists, then it uses it, otherwise, generate it. After it is generated once, it doesn't generate it again. So really just by browsing your site, you will have made all the needed sizes automatically. Just visit every page once and you are done. There is really no need for what you want to do. Unless you are pulling traffic like Amazon or Ebay;.. but still I highly doubt this would even matter.

But anyway, if you want to do it you'd need to figure out what sizes you are going to want. If you are going to use the sizes on the settings page for image sizes, then you could probably do it on product insert when you select an image, you can add the image sizes for each size you will support.

Then in the image helper location I showed above, you can just put "return;" at the very top so that it doesn't try to check if it exists. It just assumes that it will exist.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by salam110 » Tue Aug 11, 2009 2:59 am

Qphoria wrote:Unless you are pulling traffic like Amazon or Ebay;.. but still I highly doubt this would even matter.
I despair! :'(
why u think this.in every process server must create several image. if I have 3 image for one product and server must create 3 image:=> total size= 200 kB. and site have 100 visitor => 20 MB in sec.
Are u working photoshop? for create and save this size (20 MB), my PC is Thinking yet!! :o ;D :-\
but a check for exist or not is so smaller.
Qphoria wrote:But anyway, if you want to do it you'd need to figure out what sizes you are going to want. If you are going to use the sizes on the settings page for image sizes, then you could probably do it on product insert when you select an image, you can add the image sizes for each size you will support.
Then in the image helper location I showed above, you can just put "return;" at the very top so that it doesn't try to check if it exists. It just assumes that it will exist.
this is not good idea.I want a dynamic site(no static and manual.). if I have 100products, then I must 2 day busy.
u must think for worst condition and make volume of process down.
Why in each process all possible sizes is creating?
however thanks for ur answers. ;)
Last edited by salam110 on Tue Aug 11, 2009 3:08 am, edited 1 time in total.

Newbie

Posts

Joined
Tue Aug 11, 2009 1:56 am

Post by Qphoria » Tue Aug 11, 2009 3:06 am

salam110 wrote: I despair! :'(
why u think this.in every process server must create several image. if I have 3 image for one product and server must create 3 image:=> total size= 200 kB. and site have 100 visitor => 20 MB in sec
but a check for exist or not is so smaller.
I don't think you get it... It does not create several images each time. It only does it one time and then it uses the cached image. It is very clear in that system/helper/image.php file that if it already exists, don't recreate it.

That means if you goto your site ONE TIME... it will make them all ONE TIME.
Then every other customer on your site does not make an image as the images are already made.

OpenCart already does what you want it to do.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by salam110 » Tue Aug 11, 2009 3:29 am

Qphoria wrote: I don't think you get it... It does not create several images each time. It only does it one time and then it uses the cached image. It is very clear in that system/helper/image.php file that if it already exists, don't recreate it.
OpenCart already does what you want it to do.
not exactly!! OpenCart already does not.
I replace an Image in cash folder [other pic but same name] (for example: hp_1-500x500.jpg ) then click on product [in home page] (for example: hp laptop) and see the Image is created again. (for example: hp_1-500x500.jpg is created again)
How this cause?
Last edited by salam110 on Tue Aug 11, 2009 3:59 am, edited 2 times in total.

Newbie

Posts

Joined
Tue Aug 11, 2009 1:56 am

Post by salam110 » Tue Aug 11, 2009 3:42 am

Code: Select all

if (!file_exists(DIR_IMAGE . $new_image) || (filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image)))
\system\helper\image.php
I think this is not exact code?
for example:
$filename : hp_1.jpg
in cache folder is created : hp_1-500x500.jpg
in if not check hp_1-500x500.jpg in cache folder.
Note: In each time u test on ur browser clear cache's browser

Newbie

Posts

Joined
Tue Aug 11, 2009 1:56 am

Post by Qphoria » Tue Aug 11, 2009 4:17 am

I still don't understand what you mean. If you change the image using the same name, it will regenerate.

But if you upload image1.jpg
Then you goto the product page it will generate image1-500x500.jpg
Then if you goto the Homepage, it will generate image1-150x150.jpg
Then if you go back to the product it will NOT generate since image1-500x500.jpg already exists
Then if you go back to the Homepad it will NOT generate since image1-150x150.jpg already exists.

Even if 10 customers come to the product page. If that page never had a cached image, It will only generate the image for 1 customer. 9 other customers will see the already made image.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by salam110 » Tue Aug 11, 2009 4:33 am

Qphoria wrote: Even if 10 customers come to the product page. If that page never had a cached image, It will only generate the image for 1 customer. 9 other customers will see the already made image.
I understand this.I know it.
Qphoria wrote:If you change the image using the same name, it will regenerate..
How? it check file name or other? I want just check file name, not other specification.
Qphoria wrote: But if you upload image1.jpg
Then you goto the product page it will generate image1-500x500.jpg
Then if you goto the Homepage, it will generate image1-150x150.jpg
Then if you go back to the product it will NOT generate since image1-500x500.jpg already exists
Then if you go back to the Homepad it will NOT generate since image1-150x150.jpg already exists.
I go to cache folder and replace another image [using the same name: "image1-500x500.jpg"]
I go to the product page it generate "image1-500x500.jpg" again. this is not wrong? :-X ???

Newbie

Posts

Joined
Tue Aug 11, 2009 1:56 am

Post by Qphoria » Tue Aug 11, 2009 4:46 am

See in that code you posted:

Code: Select all

if (!file_exists(DIR_IMAGE . $new_image) || (filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image)))
\system\helper\image.php

if the filetime is different, even if it has same name... the image will refresh because its a new image

If you upload image1.jpg at 14:00:00
and then upload a different image1.jpg at 14:05:00
the code checks that the file time is newer than the cache file so it knows that the image changed

Don't you have images in cache folder with old times and dates? I have images in my cache from 2 weeks ago. That should prove they are not regenerating every time.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by salam110 » Tue Aug 11, 2009 9:49 am

I want just check file name, not other specification.
what is the way for this? 8)

Newbie

Posts

Joined
Tue Aug 11, 2009 1:56 am

Post by salam110 » Tue Aug 11, 2009 10:00 am

Qphoria wrote:if the filetime is different, even if it has same name... the image will refresh because its a new image
If you upload image1.jpg at 14:00:00
and then upload a different image1.jpg at 14:05:00
the code checks that the file time is newer than the cache file so it knows that the image changed
I want just check file name, not other specification.
what is the way for this? 8)
Last edited by salam110 on Tue Aug 11, 2009 10:34 am, edited 1 time in total.

Newbie

Posts

Joined
Tue Aug 11, 2009 1:56 am

Post by Qphoria » Tue Aug 11, 2009 10:28 am

change:

Code: Select all

if (!file_exists(DIR_IMAGE . $new_image) || (filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image)))
To:

Code: Select all

if (!file_exists(DIR_IMAGE . $new_image))

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by salam110 » Thu Aug 13, 2009 2:50 am

Qphoria wrote:change:

Code: Select all

if (!file_exists(DIR_IMAGE . $new_image) || (filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image)))
To:

Code: Select all

if (!file_exists(DIR_IMAGE . $new_image))
I must attend more. I don't focus on "filemtime". I'm sorry, Excuse me.
thanks.

Newbie

Posts

Joined
Tue Aug 11, 2009 1:56 am
Who is online

Users browsing this forum: Semrush [Bot] and 10 guests