gaffling / PHP-Grab-Favicon

🖼 Saves the favicon of the given URL and returns the image path.
http://suchmaschine.biz
MIT License
26 stars 6 forks source link

Split Download Folder Into Several Sub-Dirs If There Are Lot of Icons #14

Open LeeThompson opened 1 year ago

LeeThompson commented 1 year ago

Split the download dir into several sub-dirs (MD5 segment of filename e.g. /af/cd/example.com.png) if there are a lot of favicons.

@gaffling How did you want this to work?

My general thought is if the number of requested icons > the threshold set by default, ini or switch then instead of just using local_path it will create sub-folders based on fragments of the md5 hashes of the icons for saving.

Although it might be better if it was alpha based on the domain name, like "microsoft" would go in "m/microsoft.com.ico". Perhaps there could be multiple threshold levels so perhaps "mi/microsoft.com.ico" if there are a crazy number.

gaffling commented 1 year ago

I have done such a thing before and I would split the first 2 chars of the filename and then check if a folder like this exists and if not build it and save the file ;-)

And yes, use the complete domain as a filename seems to be a good idea!