Results 1 to 8 of 8
  1. #1
    Join Date
    May 2008
    Posts
    4
    Plugin Contributions
    0

    Default Product image file name

    It seems when you upload a product image it will save the image to the server using the images original file name.

    Would it be possible to have zen cart assign the uploaded image a random file name so that you dont run into the problem of overwriting an image that belongs to a different product?

    I've looked through the code for about an hour and cant seem to find where to even start correcting this. Has anyone already done it?

  2. #2
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Product image file name

    You may want to look at Image Handler 2 to manage your product images.

    Alternatively, you can choose not to overwrite an existing image when you select an image in product creation, so this should alert you to any impending problems.

  3. #3
    Join Date
    May 2008
    Posts
    4
    Plugin Contributions
    0

    Default Re: Product image file name

    Isnt Image Handler 2 used for creating thumbnails? I dont think it cares much about file name.

    As for the overwrite option, I have changed the default to no in the code. This is not exactly a fix however. I would prefer the filenames to either be random or be given an ID such as the item number to prevent any mistakes.

    I find it odd that the system wasnt build this way in the first place.

  4. #4
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Product image file name

    The system was built for people who knew what they were doing when giving names to images. Assigning random names or even the product id eliminates the possibility of owners using a system that is meaningful to them.
    If an owner wants to update product images, a random or fixed naming system makes it impossible to easily tell which images are new or old.

  5. #5
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Product image file name

    Another point is that for some sites, some products may share an image. Automatically assigned names eliminate this possibility and require a separate copy for each product.

    However, having an option to automatically assign filenames when saving images would be a good thing for those who want it. A random name makes it impossible for humans to manage images manually; a name based on the product id would be short, unique and possible to manage.
    Last edited by gjh42; 29 May 2008 at 12:38 AM.

  6. #6
    Join Date
    May 2008
    Posts
    4
    Plugin Contributions
    0

    Default Re: Product image file name

    My problem is that the owner of the site isnt exactly computer literate. He just wants to be able to upload anything and not have to check if a file name exists first .

    As for new and old images. Unless you need to keep an old image, not sure why you would, the new one would replace it.

    In the case of multiple items sharing the same image, one product is the owner of the image and the others get the image file name pasted into the "select an existing image file from server" box.

  7. #7
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Product image file name

    For your client's situation, I can see an auto-generated filename being useful.
    In general, I don't like the idea of dumbing down the system to reduce operator flexibility.

    There would be no way to tell if you had already replaced an image if the filename is forced to stay the same, and an automatic system would by definition rename or make a new copy of a file given to it. If you can bypass that, you no longer have a foolproof system.

    At any rate, it would be a trivial matter in the product creation code to look up the current product's id and build the filename to use; changing the actual filename while saving it should be possible for one who knows the Zen Cart code and PHP thoroughly. Then the option of using an existing filename has to be eliminated, possibly while copying an existing file from the ZC folders. Finally, a switch in admin to turn this feature on & off might be a good thing.

  8. #8
    Join Date
    May 2008
    Posts
    4
    Plugin Contributions
    0

    Default Re: Product image file name

    I've been reading the code. It seems that for a new product, the ID is not set until after the preview page however the image is saved to the folder before hand.

    If this is the case, if you change your mind and press the back button on the preview page the image will be left on the server - I havent seen anything that goes back and deletes it yet. (untested)

    Without a major rewrite, best the way of doing this would be to assign it a random name and then go back and change it after the ID has been set.

    35% complete in coding it

 

 

Similar Threads

  1. Image File Name Length How To Change?
    By kenaniah in forum General Questions
    Replies: 6
    Last Post: 13 Mar 2012, 03:18 PM
  2. need a quick fix!! image file name renameing
    By kitcorsa in forum General Questions
    Replies: 2
    Last Post: 10 May 2010, 09:55 AM
  3. Upload image file name probelm
    By hillbun in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 9 Feb 2009, 05:41 AM
  4. What is the function to generate image file name in IH2?
    By suman07 in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 16 Dec 2007, 01:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg