Not signed in (Sign In)

Vanilla 1.1.10 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorandrewjs18
    • CommentTimeApr 28th 2009
     
    As the title says, the truncate doesn't work in the admin panel. Trying to shrink the name of the files within the gallery.

    Thanks,
    Andrew
  1.  
    anybody?
  2.  
    still no replies? support board is dead. =( only thing plogger lacks is better support.
    •  
      CommentAuthorsidtheduck
    • CommentTimeJun 3rd 2009 edited
     
    Sorry, I lost track of your thread. This should be fixed in the current codebase already. You can download and test out the code here.
  3.  
    <blockquote><cite>Posted By: sidtheduck</cite>Sorry, I lost track of your thread. This should be fixed in the current codebase already. You can download and test out the code<a href="http://dev.plogger.org/changeset/599/trunk?old_path=%2F&format=zip">here</a>.</blockquote>

    sidtheduck,

    I installed/upgraded with the provided link-went into admin cp and chose the truncate=5 option and saved it and then cleaned cache from browse and the picture name is still more than 5 characters...here's my breadcrumb to a photo:
    Ugly-Cars » Personal Photos » 9451784756_orig.jpg
    • CommentAuthorandrewjs18
    • CommentTimeJun 11th 2009
     
    still isn't working.

    sidtheduck,

    please advise..I can give you access to my ftp if you need to check out some files or get into my control panel for the gallery.
    • CommentAuthorandrewjs18
    • CommentTimeJun 23rd 2009
     
    Sid,

    anymore developments to get this to work properly?
    •  
      CommentAuthorsidtheduck
    • CommentTimeJun 23rd 2009
     
    Sorry, I meant to respond.

    The truncate option is only used for display purposes. It wasn't ever intended to truncate the actual filename.

    If you want to truncate the filename, you need to let me know if you are using the latest SVN code or the beta3 code that you downloaded from the main Plogger page and I can let you know how to edit the function.
    • CommentAuthorandrewjs18
    • CommentTimeJun 24th 2009
     
    I'm using the 599 trunk.
  4.  
    sid, I let you know what trunk I'm using so please advise.
    •  
      CommentAuthorsidtheduck
    • CommentTimeJul 2nd 2009 edited
     
    Sorry about that andrewjs18, it's been a little hectic around here.

    To do the truncate filename in the 599 trunk, open plog-includes/plog-functions.php and find the following code (should be around line 1293):
    function sanitize_filename($str) {
    // Allow only alphanumeric characters, hyphen, and dot in file names
    // Spaces will be changed to dashes, special chars will be suppressed, & the rest will be replaced with underscores
    $special_chars = array ('#', '$', '%', '^', '&', '*', '!', '~', '"', '\'', '=', '?', '/', '[', ']', '(', ')', '|', '<', '>', ';', ':', '\\', ', ');
    $str = str_replace($special_chars, '', $str);
    $str = str_replace(' ', '-', $str);
    return preg_replace("/[^a-zA-Z0-9\-\.]/", "_", $str);
    }

    and change it to read:
    function sanitize_filename($str) {
    // Allow only alphanumeric characters, hyphen, and dot in file names
    // Spaces will be changed to dashes, special chars will be suppressed, & the rest will be replaced with underscores
    $special_chars = array ('#', '$', '%', '^', '&', '*', '!', '~', '"', '\'', '=', '?', '/', '[', ']', '(', ')', '|', '<', '>', ';', ':', '\\', ', ');
    $str = str_replace($special_chars, '', $str);
    $str = str_replace(' ', '-', $str);
    $str = preg_replace("/[^a-zA-Z0-9\-\.]/", "_", $str);
    if (intval($config['truncate']) > 0 && isset($str{intval($config['truncate'])})) {
    $str = substr($str, 0, intval($config['truncate']));
    }
    return $str;
    }

    That should work for you!
  5.  
    getting this error:

    Parse error: syntax error, unexpected T_STRING in /home/uglycars/public_html/uglycars/gallery/plog-includes/plog-functions.php on line 1388

    I found the code you said on line 1382.
    •  
      CommentAuthorsidtheduck
    • CommentTimeJul 3rd 2009
     
    Posted By: andrewjs18getting this error:

    Parse error: syntax error, unexpected T_STRING in /home/uglycars/public_html/uglycars/gallery/plog-includes/plog-functions.php on line 1388
    Sorry, I should have checked my work. I missed an equals (=) sign on the 6th line from the bottom. I fixed my post above, so you can re-copy it and it should work for you.
  6.  
    Posted By: sidtheduck
    Posted By: andrewjs18getting this error:

    Parse error: syntax error, unexpected T_STRING in /home/uglycars/public_html/uglycars/gallery/plog-includes/plog-functions.php on line 1388
    Sorry, I should have checked my work. I missed an equals (=) sign on the 6th line from the bottom. I fixed my post above, so you can re-copy it and it should work for you.



    did that, uploaded it, overwrote old file and now get this error:
    Notice: Undefined variable: config in /home/uglycars/public_html/uglycars/gallery/plog-includes/plog-functions.php on line 1389
    •  
      CommentAuthorsidtheduck
    • CommentTimeJul 3rd 2009
     
    Okay, didn't test it before. Sorry again. You need to define $config as a global variable. So your function code should now look like this:
    function sanitize_filename($str) {
    global $config;
    // Allow only alphanumeric characters, hyphen, and dot in file names
    // Spaces will be changed to dashes, special chars will be suppressed, & the rest will be replaced with underscores
    $special_chars = array ('#', '$', '%', '^', '&', '*', '!', '~', '"', '\'', '=', '?', '/', '[', ']', '(', ')', '|', '<', '>', ';', ':', '\\', ', ');
    $str = str_replace($special_chars, '', $str);
    $str = str_replace(' ', '-', $str);
    $str = preg_replace("/[^a-zA-Z0-9\-\.]/", "_", $str);
    if (intval($config['truncate']) > 0 && isset($str{intval($config['truncate'])})) {
    $str = substr($str, 0, intval($config['truncate']));
    }
    return $str;
    }
  7.  
    Ok, I did it...no error this time, but I don't notice any change in the actual file name in the galleries. Do I need to run anything to get it to update the photos?

    here's a breadcrumb going to 1 of my photos:

    Ugly-Cars » Web Photos » bvwi9oqbmkkgrhgoh-cyejlll8jjfbkscur5s2q_1.JPG
    •  
      CommentAuthorsidtheduck
    • CommentTimeJul 4th 2009
     
    andrewjs,

    This will only work for newly uploaded photos, not existing ones. I could maybe come up with something that will cycle through all of your existing files, but it will take me a little while, since I am busy this weekend.
  8.  
    Sid,

    I may test tonight by uploading a photo after work and I may just delete all the photos and reupload them to make it easier on you.