Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Automatic Thumbnail Contribution Glitch?


osDJ

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

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?

Link to comment
Share on other sites

Hi,

 

How would one go about writing such a script?

 

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

Link to comment
Share on other sites

Hi,

 

How would one go about writing such a script?

 

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...