Forums / All Other Contributions/Addons / Image Handler - Extra BMZ folders for GoDaddy (and other cheapie hosts) users mod.

Image Handler - Extra BMZ folders for GoDaddy (and other cheapie hosts) users mod.

Views: 8,142

Results 1 to 12 of 12
2 Jan 2013, 4:34 AM
#1
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Image Handler - Extra BMZ folders for GoDaddy (and other cheapie hosts) users mod.

This is not the Image handler support thread, that is here

This is for Image Handler users who are hosted by GoDaddy (and other bucket hosts) who are falling foul of Godaddys limit of 1024 files per folder rule in your bmz_cache subfolders, where the optimised images are placed by image handler.

With most decent hosts you shouldn't need to do this as they don't have issues with you exceeding the 1024 files per folder.

Anyway Here goes

@ You Go Daddy users

First off Image handler should be installed and working correctly, if it isn't working correctly in the first place, this won't fix it.

This is an unsupported change to a core image handler file, which may help you Go-Daddy fans

This hasn't been heavily tested so USE AT YOU OWN RISK, I make no guarantees whatsoever

from line 71 in your
/includes/functions/extra_functions/functions_bmz_io.php

function getCacheName($data, $ext='') {
  global $bmzConf;

  $md5  = md5($data);
  $file = $bmzConf['cachedir'] . '/' . $md5{0} . '/' . $md5.$ext;
  io_makeFileDir($file);
  return $file;
}

try replacing it with this

function getCacheName($data, $ext='') {
  global $bmzConf;

  $md5  = md5($data);
//  $file = $bmzConf['cachedir'] . '/' . $md5{0} . '/' . $md5.$ext;
  $file = $bmzConf['cachedir'] . '/' . substr($md5,0,2) . '/' . $md5.$ext;
  io_makeFileDir($file);
  return $file;
}

Currently Image Handler uses the first character of the optimised image for the sub directory name in your bmz_cache folder, so you will have 16 sub folders 0-f (hexidecimal), The change above instead take the first 2 characters of the optimised image name giving you 256 subfolders in the bmz_cache, so this should mean less images in each folder.

And just a note, there is no point trying to take the first 3 chars as that will give you 4096 folders which might kill the hamster that runs Go-Daddy

Webzings Design
Semi retired from Web Design

2 Jan 2013, 1:16 PM
#2
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Image Handler - Extra BMZ folders for GoDaddy (and other cheapie hosts) users mod.

nigelt74:

...which might kill the hamster that runs Go-Daddy

I didn't know GoDaddy has such as sophisticated system as this. Last I heard they we still using a shaduf.

20 years a Zencart User

2 Jan 2013, 9:17 PM
#3
edsgoodstuff avatar

edsgoodstuff

New Zenner

Join Date:
Oct 2012
Posts:
25
Plugin Contributions:
0

Re: Image Handler - Extra BMZ folders for GoDaddy (and other cheapie hosts) users mod.

Backed up the database and was about to try the code change on live site but had second thoughts. Not sure if this can be undone simply by replacing original code/php file or if will have effects on the rest of the site and database? By that I mean more "permanent" changes than just creating the 256 files which assume could be just deleted if issues occur.

Going to try installing in my test cart as soon as I get some time. Test cart doesn't have Image Handler or the other plugins that live site has so have to take care of that first.

Will post results here. Thanks again. If this works maybe they can give that hamster a little time off.

3 Jan 2013, 7:26 AM
#4
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Re: Image Handler - Extra BMZ folders for GoDaddy (and other cheapie hosts) users mod.

This change has zero effect on the database, and the folders can be deleted if you so wish, you can either delete them manually or via Image Handlers Purge folders function.

To undo the change simply revert the code, upload the file and then purge the folders and its all like it was before,

Webzings Design
Semi retired from Web Design

3 Jan 2013, 7:26 AM
#5
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Re: Image Handler - Extra BMZ folders for GoDaddy (and other cheapie hosts) users mod.

This change has zero effect on the database, and the folders can be deleted if you so wish, you can either delete them manually or via Image Handlers Purge folders function.

To undo the change simply revert the code, upload the file and then purge the folders and its all like it was before,

Webzings Design
Semi retired from Web Design

3 Jan 2013, 7:27 AM
#6
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Re: Image Handler - Extra BMZ folders for GoDaddy (and other cheapie hosts) users mod.

In fact that point was so important i thought I'd say it twice.

Stupid buttons

Webzings Design
Semi retired from Web Design

3 Jan 2013, 7:31 AM
#7
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Re: Image Handler - Extra BMZ folders for GoDaddy (and other cheapie hosts) users mod.

schoolboy:

I didn't know GoDaddy has such as sophisticated system as this. Last I heard they we still using a shaduf.

Dunno where you heard that, a Shaduf would be a bit tooo technical wouldn't it

Having said that, i do use Go-Daddy for all my .com domain registrations

Webzings Design
Semi retired from Web Design

13 Jan 2013, 7:47 PM
#8
edsgoodstuff avatar

edsgoodstuff

New Zenner

Join Date:
Oct 2012
Posts:
25
Plugin Contributions:
0

Re: Image Handler - Extra BMZ folders for GoDaddy (and other cheapie hosts) users mod.

OK, finally got test cart pretty much set up the same way as live cart.

I changed the code in TEST_CART/includes/functions/extra_functions/functions_bmz_io.php as suggested.

At first result was blank pages at my test cart home page for a while and Server 500 errors but after a minute or so and refreshing the page eventually started to load. Checked the bmz_cache folder and still only 16 directories. all with one character filenames. Tried it a few more times, tried clearing cache in Image Handler Admin Tools, different browser, and a few other things but no change.

Then I tried the code change on TEST_CART/MY_ADMIN/includes/functions/extra_functions/functions_bmz_io.php

Result was lots of new directories in the bmz_cache folder all with two character filenames as expected. My test cart home page seems to be working fine and all images seem to load quickly.

Wondering if I did something wrong? And should change the TEST_CART/includes/functions/extra_functions/functions_bmz_io.php back to the original file or just leave it as is?

Thanks, Ed

15 Jan 2013, 5:31 AM
#9
edsgoodstuff avatar

edsgoodstuff

New Zenner

Join Date:
Oct 2012
Posts:
25
Plugin Contributions:
0

Re: Image Handler - Extra BMZ folders for GoDaddy (and other cheapie hosts) users mod.

Update:

I cleared the bmz_cache folder and then changed TEST_CART/includes/functions/extra_functions/functions_bmz_io.php back to the original unmodified file and instantly got page unavailable errors. A few minutes later was able to access the test cart home page again, checked the bmz_cache and saw it went back to 16 directories.

There seems to be a certain period of time after you change the file where it takes the site offline. Changing the TEST_CART/MY_ADMIN/includes/functions/extra_functions/functions_bmz_io.php was apparently not necessary- waiting a little while is probably all that was needed.

Replaced TEST_CART/includes/functions/extra_functions/functions_bmz_io.php with the modded file again and it's back to the way it was with the extra directories, everything seems to be working well.

Am wondering if there is any reason to also change the TEST_CART/MY_ADMIN/includes/functions/extra_functions/functions_bmz_io.php to include the new code, and what exactly the file does in the MY_ADMIN folder?

15 Jan 2013, 5:43 AM
#10
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Re: Image Handler - Extra BMZ folders for GoDaddy (and other cheapie hosts) users mod.

The delay must be a godaddy thing mine worked instantly, did you try accessing with a different browser? to eliminate cacheing issues

Webzings Design
Semi retired from Web Design

15 Jan 2013, 3:41 PM
#11
edsgoodstuff avatar

edsgoodstuff

New Zenner

Join Date:
Oct 2012
Posts:
25
Plugin Contributions:
0

Re: Image Handler - Extra BMZ folders for GoDaddy (and other cheapie hosts) users mod.

Thanks for the reply.

Yes, tried with Firefox, Chrome, and IE. And also on a different computer. Firefox and IE showed blank pages while Chrome showed a server 500 error. This occurred both when I changed the file to modified version and back to the original.

The test cart now appears to be working fine with modified file.

21 Jul 2013, 6:54 PM
#12
gameoverbeyond avatar

gameoverbeyond

New Zenner

Join Date:
May 2007
Posts:
41
Plugin Contributions:
0

Re: Image Handler - Extra BMZ folders for GoDaddy (and other cheapie hosts) users mod.

Worked with no problems on test server, will report back when uploaded to live site.