osDJ Posted February 5, 2005 Share Posted February 5, 2005 This is a new osc account as the one I set up a few months ago is impossible for me to access now (forgot login, closed email account). Anyway, I installed the "automatic thumbnail" contribution as found here http://www.oscommerce.com/community/contributions,1484 . It works wonderfully on the pictures I have with standard file names such as http://www.dans-jewelers.com/images/steelskull.jpg . However, 95% of my pictures contain %20 in their name such as this one: http://www.dans-jewelers.com/images/newpics1%20016.jpg . It seems that the contribution does nothing with these files. 1. Can the code be salvaged somehow to work with my pictures? Renaming each of the 1500 or so pictures I don't think is really an option. 2. Will the other image contributions give me similar problems? Thanks, Daniel Quote Link to comment Share on other sites More sharing options...
osDJ Posted February 9, 2005 Author Share Posted February 9, 2005 Any ideas on this one? I really like this contribution and wish it would be able to work. Most of my pictures have a space in the name and it'd take hours and other complications I'm afraid to rename them. This might be an easy one for somebody. I'll send you $5 by paypal if you could show me an easy modification to the code that would make it work. Quote Link to comment Share on other sites More sharing options...
peterr Posted February 14, 2005 Share Posted February 14, 2005 Daniel, As a 'web standard', you really shouldn't have images names that contain spaces, as some browsers _do_ have problems with them, and links in emailers can also not 'translate' properly. You would be better to rename the files, it's not much work really, just do it in a script. Peter Quote Link to comment Share on other sites More sharing options...
osDJ Posted February 16, 2005 Author Share Posted February 16, 2005 Daniel, As a 'web standard', you really shouldn't have images names that contain spaces, as some browsers _do_ have problems with them, and links in emailers can also not 'translate' properly. You would be better to rename the files, it's not much work really, just do it in a script. Peter <{POST_SNAPBACK}> I agree with you completely Peter. Back in the early days of my business before I thought about the broader implications, I just took my pictures and put them online. My camera automatically named them with the space. How would one go about writing such a script? Quote Link to comment Share on other sites More sharing options...
peterr Posted February 16, 2005 Share Posted February 16, 2005 Hi, How would one go about writing such a script? <{POST_SNAPBACK}> To my simple thinking, ............ 1. Get all the filenames in the ../images path. 2. Loop thru and check the length, then remove anys spaces in the filename, and check the length again. 3. If as a result from step 2, the 'lengths' differ, then you do this..... (i) Create the code to do the rename (ii) Build an SQL statement to do an "update products ......" to change the image name. 4. It's just a broad overview, and it needs a few sql queries, but that is really all you need as an objective, rename the image, and update that row for that image. Peter Quote Link to comment Share on other sites More sharing options...
peterr Posted February 18, 2005 Share Posted February 18, 2005 Hi, How would one go about writing such a script? <{POST_SNAPBACK}> Here is a start on the script, not real flash, and it only traverses your image path and echos any filenames with spaces, tells you the length, and the 'new' length. You can safely run this in your catalog or 'web root' path, just below the image path that is. <?php $dir = "images/"; // Open a known directory, and proceed to read its contents if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if (filetype($dir . $file) == "file") { $filelength = strlen($file); // replace any spaces in the filename with nulls $filename = str_replace(" ", "", $file); $filelength_new = strlen($filename); if ($filelength != $filelength_new) { echo "file length = " . $filelength . "<br>"; echo "filename: $file : filetype: " . filetype($dir . $file) . "<br>"; echo "new filename = " . $filename . "<br>"; echo "new file length = " . $filelength_new . "<br>"; } } } closedir($dh); } } ?> More later, hopefully, if I get to it. Peter Quote Link to comment Share on other sites More sharing options...
peterr Posted February 18, 2005 Share Posted February 18, 2005 Hi, You can safely run this in your catalog or 'web root' path, just below the image path that is. <{POST_SNAPBACK}> Oops, I meant just 'above' your image path, but you knew that, didn't you. :D Peter Quote Link to comment Share on other sites More sharing options...
peterr Posted February 18, 2005 Share Posted February 18, 2005 Hi, The PHP script is finished, if anyone has a need for it ?? Peter Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.