Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    Jul 2005
    Location
    Orlando, Fl
    Posts
    324
    Plugin Contributions
    0

    Default Product Image upload to SubDirectories?

    PHP Version: 7.1.33 -- ZC 156

    Hello, is there way to modify zen_draw_pull_down_menu or zen_build_subdirectories_array or create an extra function to loop through all subfolders in the images directory.

    So we can upload product photography into specific sub folders?

    Thanks in Advance

    ~D

  2. #2
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Product Image uploader Sub Categories

    Quote Originally Posted by djdavedawson View Post
    PHP Version: 7.1.33 -- ZC 156

    Hello, is there way to modify zen_draw_pull_down_menu or zen_build_subdirectories_array or create an extra function to loop through all subfolders in the images directory.

    So we can upload product photography into specific sub folders?

    Thanks in Advance

    ~D
    Is this specific to a particular plugin (should seek the forum for it) or just a general issue with uploading images through say the product screen? The product area has a dropdown of the image folders to support specifying to where the image is to be stored. Note that the last image uploaded will become the base image for the product.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Jul 2005
    Location
    Orlando, Fl
    Posts
    324
    Plugin Contributions
    0

    Default Re: Product Image uploader Sub Categories

    These are core ZC functions that create the dropdown list on the edit product or new product page.

    The dropdown gives upload locations for the images by reading the images directory's contained folders.

    PHP Code:
    zen_draw_pull_down_menu -> html_output.php

    zen_build_subdirectories_array 
    -> collect_info.php 
    So for example, if we want to setup the images folder like this:

    Code:
    cars
    cars/blue
    cars/red
    
    bikes
    bikes/street
    bikes mountain
    
    shoes
    shoes/big
    shoes/small
    The core function only produces this for upload locations:
    Code:
    cars
    
    bikes
    
    shoes
    Where we would like to be able to select from the whole folder list like so:

    Code:
    cars
    cars/blue
    cars/red
    
    bikes
    bikes/street
    bikes mountain
    
    shoes
    shoes/big
    shoes/small
    Thanks for the quick reply

  4. #4
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,571
    Plugin Contributions
    30

    Default Re: Product Image uploader Sub Categories

    So what you really want is to be able to select images from an folder below the /images folder, not just the current one-level subdirectory limit.

    That seems a reasonable request / I wonder why it does not do that anyway?
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

  5. #5
    Join Date
    Jul 2005
    Location
    Orlando, Fl
    Posts
    324
    Plugin Contributions
    0

    Default Re: Product Image uploader Sub Categories

    Yes, I want to select where the images upload to and include sub folders in the images directory.

  6. #6
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Product Image uploader Sub Categories

    Quote Originally Posted by torvista View Post
    So what you really want is to be able to select images from an folder below the /images folder, not just the current one-level subdirectory limit.

    That seems a reasonable request / I wonder why it does not do that anyway?
    The code has/had comments to make it traversable and therefore support display of sub-directories of sub-directories. One thing though, note that the sub-directory information will become part of your image path's filename. Normally not a big problem, but that path name has a "preset" limit (which can be adjusted to the needed size). But, it is the number of characters associated with the folder/sub-folder with dividers and filename plus extension... size changed in versions "recently".

    I've been looking today about what it would take to do the recursive look "simply" but seems to lead back to the simple use of the recursiveIterator "class".
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Jul 2005
    Location
    Orlando, Fl
    Posts
    324
    Plugin Contributions
    0

    Default Re: Product Image uploader Sub Categories

    Quote Originally Posted by mc12345678 View Post
    seems to lead back to the simple use of the recursiveIterator "class".
    Here's what I put together, seems to work so far.

    Not sure about bigger picture stuff.

    PHP Code:

    function new_zen_build_subdirectories_array($parent_folder ''$default_text 'Main Directory') { 

        if (
    $parent_folder == ''$parent_folder DIR_FS_CATALOG_IMAGES;

        
    $dir_info[] = array('id' => '''text' => $default_text);

        
    $iter = new RecursiveIteratorIterator(
                    new 
    RecursiveDirectoryIterator($parent_folderRecursiveDirectoryIterator::SKIP_DOTS),
                    
    RecursiveIteratorIterator::SELF_FIRST,
                    
    RecursiveIteratorIterator::CATCH_GET_CHILD 
        
    );

        
    $paths = array($parent_folder);

        foreach (
    $iter as $path => $dir) {

            if (
    $dir->isDir()) {    

                
    $path str_replace($parent_folder''$path);
                
    $dir_info[] = array('id' => $path '/''text' => $path);

            }

        }
        
        
    sort($dir_info);
        return 
    $dir_info;


  8. #8
    Join Date
    Jul 2005
    Location
    Orlando, Fl
    Posts
    324
    Plugin Contributions
    0

    Default Re: Product Image uploader Sub Categories

    Only issue I see right now is that some folders would NEED to be skipped.

    This is how it would render:

    cars
    cars/blue
    cars/red
    shoes
    shoes/big
    shoes/small

    In my case, I wouldn't need cars or shoes, just this:

    cars/blue
    cars/red
    shoes/big
    shoes/small

    I was able to solve it by coding it in but this wouldn't work for everyone.

    PHP Code:

    $skip 
    = array("cars","shoes"); 
    ...

    PHP Code:
    if (!in_array($path,$skip)) {

    $dir_info[] = array('id' => $path '/''text' => $path);
                    

    Could have it exclude parents but some users may want them

    Maybe an admin item for directories to skip OR Skip Parents on/off. IDK

    ~D

  9. #9
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Product Image uploader Sub Categories

    Perhaps explains a reason why it hasn't been implemented yet. There's many variations on the same theme with which to consider.

    So what is the real benefit that you're gaining if only interested in the outer "leafs" of the tree? I mean, why not just have image directories called: cars-blue, cars-red, shoes-big, shoes-small?

    I believe/suspect that there is an option available to request only the outer leafs be returned which is what is described above as requested.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  10. #10
    Join Date
    Jul 2005
    Location
    Orlando, Fl
    Posts
    324
    Plugin Contributions
    0

    Default Re: Product Image uploader Sub Categories

    Yeah, that's a good point and solution, we can chalk one up to Proper Planning.

    It's a bit different than traditional file organization, but it works. Especially for small sites.

    Will new users know do this?

    Most of us use sftp and a db editor are not really impacted by this, it's more of an issue for the end-users of the backend.

    Existing sites with a file structure similar to how I've described above would need to re configure their image mappings, seo-redirects, etc.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Product upload image problème
    By fincosat in forum General Questions
    Replies: 5
    Last Post: 15 May 2010, 09:24 PM
  2. Product image upload directory
    By JayEx in forum Customization from the Admin
    Replies: 1
    Last Post: 4 Jun 2008, 06:59 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR