Not signed in (Sign In)

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

    • CommentAuthorelias75
    • CommentTimeApr 15th 2009
     
    Just installed the Version 3.0 Beta and have to say that Plogger ROCKS!

    I have the following question though.... would it be possible to change all captions (or just fill them cause they are blank now) with the file name? But without the "_"'s ??

    what I mean is this:
    the original photo on my hard disc is named "The Addams Family" after the upload etc the file is now named "the_addams_family" which I don't have a problem with that.... but... can I make the caption of this photo to be "The Addams Family" (to be named after the file name) but without the "_"'s in between words?? - of course this can be done easily via the Manage menu, but I need this to be done in about 4000 photos.....!!! any help would be much appreciated otherwise it will take me a few good months to make it :(

    many thanks in advance!
    • CommentAuthorelias75
    • CommentTimeApr 16th 2009
     
    anyone?

    please let me know if this can be done, I need to do this in more than 4000 photos....

    cheers
    •  
      CommentAuthorsidtheduck
    • CommentTimeApr 16th 2009 edited
     
    elias75,

    Make a new file in a text editor (like Notepad) and place the following code in it:

    UPDATE: See this post for code

    Then save the file as something like 'name-caption.php'. Upload the file to the Plogger folder on your server (same directory as gallery.php) and then navigate to the file in your browser (http://yoursite.com/plogger/name-captoin.php). It will update the Caption based on the filename, stripping the file extension, replacing underscores with spaces, and capitalizing the first letter of each word. Once you're done, just delete the file from your server to keep it from overwriting any changes you make to the caption after the fact.

    Hope that helps! :D
    • CommentAuthorelias75
    • CommentTimeApr 22nd 2009
     
    sidtheduck,

    sorry for my late response but I was away from my pc for a few days... this looks cool! I will definitely try it out!
    Right now I am stuck with some other project and in 1-2 days time I will work entirely on this.

    I will report any progress here and also showcase my site with plogger to those who might want to see how it interacts with bid amounts of photos 4000 and more!

    cheers, talk to you very soon!

    elias75
    • CommentAuthorelias75
    • CommentTimeApr 23rd 2009
     
    Hello sidtheduck,

    ok I did what you mentioned and this is what happened: the script updated the caption of the first 10-15 files and then stopped giving me this message:

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '84 ' WHERE `path` = 'index/a/aftermath__'84_.JPG'' at line 1

    UPDATE `plogger_pictures` SET `caption` = 'Aftermath '84 ' WHERE `path` = 'index/a/aftermath__'84_.JPG'

    In file: /ploggerb3/name-caption.php

    On line: 11

    I guess there is some bit of code that needs a small change or something but since I am a complete newbie with php I am not quite sure what it might be....

    the file it stopped is named "Aftermath '84" perhaps that " <strong>' </strong>" apostrophe did the damage....
    •  
      CommentAuthorsidtheduck
    • CommentTimeApr 23rd 2009
     
    Yep, it's the ( ' ) that stopped the code. You should make this change to the code above:
    $sql = "UPDATE `plogger_pictures` SET `caption` = '".$basename."' WHERE `path` = '".addcslashes($row['path'], "'")."'";

    That should do it for you. I forgot that the old 1.0b3 code allowed for single quotes within a filename (the new code strips it out).
    • CommentAuthorelias75
    • CommentTimeApr 23rd 2009
     
    still the same...
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '84 ' WHERE `path` = 'index/a/aftermath__\'84_.JPG'' at line 1

    UPDATE `plogger_pictures` SET `caption` = 'Aftermath '84 ' WHERE `path` = 'index/a/aftermath__\'84_.JPG'

    In file: /ploggerb3/name-caption.php

    On line: 11

    I replaced this line:
    $sql = "UPDATE `plogger_pictures` SET `caption` = '".$basename."' WHERE `path` = '".$row['path']."'";
    $sql_result = run_query($sql);

    with this:
    $sql = "UPDATE `plogger_pictures` SET `caption` = '".$basename."' WHERE `path` = '".addcslashes($row['path'], "'")."'";
    •  
      CommentAuthorsidtheduck
    • CommentTimeApr 23rd 2009
     
    Nuts, sorry about that. Try this:
    $sql = "UPDATE `plogger_pictures` SET `caption` = '".$basename."' WHERE `path` = '".mysql_real_escape_string($row['path'])."'";
    • CommentAuthorelias75
    • CommentTimeApr 23rd 2009
     
    no... again the same message
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '84 ' WHERE `path` = 'index/a/aftermath__\'84_.JPG'' at line 1

    UPDATE `plogger_pictures` SET `caption` = 'Aftermath '84 ' WHERE `path` = 'index/a/aftermath__\'84_.JPG'

    In file: /ploggerb3/name-caption.php
    •  
      CommentAuthorsidtheduck
    • CommentTimeApr 23rd 2009 edited
     
    Weird, it should be fine now. However, we'll go a different route:
    $sql = "UPDATE `plogger_pictures` SET `caption` = '".$basename."' WHERE `id` = ".$row['id'];
    • CommentAuthorelias75
    • CommentTimeApr 23rd 2009
     
    again not much, slightly different message:

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '84 ' WHERE `id` = 17' at line 1

    UPDATE `plogger_pictures` SET `caption` = 'Aftermath '84 ' WHERE `id` = 17

    In file: /ploggerb3/name-caption.php
    •  
      CommentAuthorsidtheduck
    • CommentTimeApr 23rd 2009 edited
     
    DOH! I was escaping the wrong entry. Try this:
    $sql = "UPDATE `plogger_pictures` SET `caption` = '".mysql_real_escape_string($basename)."' WHERE `id` = ".$row['id'];

    I SWEAR that should do it! :D
    • CommentAuthorelias75
    • CommentTimeApr 23rd 2009
     
    this time I got the

    Error updating caption for the"+++++++++++"

    for all file names....
    •  
      CommentAuthorsidtheduck
    • CommentTimeApr 23rd 2009
     
    hmmm ... I just tested it on my server with a filename with a single quote in it and it works.

    Here's my full code:
    <?php
    include(dirname(__FILE__).'/gallery.php');
    $query = "SELECT * FROM `plogger_pictures` WHERE 1";
    $result = run_query($query);
    while ($row = mysql_fetch_assoc($result)) {
    $basename = basename($row['path']);
    $basename = substr($basename, 0, strrpos($basename, '.'));
    $basename = str_replace('_', ' ', $basename);
    $basename = ucwords(strtolower($basename));
    $sql = "UPDATE `plogger_pictures` SET `caption` = '".mysql_real_escape_string($basename)."' WHERE `id` = ".$row['id'];
    $sql_result = run_query($sql);
    if (!$sql_result) {
    echo "\n".'<li>Error updating caption for '.basename($row['path']).'</li>';
    } else {
    echo "\n".'<li>Updated caption to <strong>'.$basename.'</strong></li>';
    }
    }
    echo "\n".'<br />Done!';
    ?>
    • CommentAuthorelias75
    • CommentTimeApr 23rd 2009
     
    so cool, I made a new php file with the full code and run it again and it works!

    you rule!!!!

    is it ok to leave this on my root directory so every time I upload new photos the caption will update?
    or is it better to upload this file only when I need it to change the captions??

    please also edit this thread accordingly so people with the same question will just use the code and will not go through all the different lines.

    as I said, once I finish my gallery, I will post here for everyone to see how plogger does with 1000's of images

    donation on the way!

    many thanks man!
    •  
      CommentAuthorsidtheduck
    • CommentTimeApr 23rd 2009 edited
     
    Sure you can leave it on your root directory. The only issue would be if you alter your caption (in case the auto generation of the caption isn't quite right). This will always save over the existing captions. If you want it to only copy to the captions that are blank you can alter it like so:
    <?php
    include(dirname(__FILE__).'/gallery.php');
    $query = "SELECT * FROM `plogger_pictures` WHERE 1";
    $result = run_query($query);
    while ($row = mysql_fetch_assoc($result)) {
    if (empty($row['caption'])) {
    $basename = basename($row['path']);
    $basename = substr($basename, 0, strrpos($basename, '.'));
    $basename = str_replace('_', ' ', $basename);
    $basename = ucwords(strtolower($basename));
    $sql = "UPDATE `plogger_pictures` SET `caption` = '".mysql_real_escape_string($basename)."' WHERE `id` = ".$row['id'];
    $sql_result = run_query($sql);
    if (!$sql_result) {
    echo "\n".'<li>Error updating caption for '.basename($row['path']).'</li>';
    } else {
    echo "\n".'<li>Updated caption to <strong>'.$basename.'</strong></li>';
    }
    }
    }
    echo "\n".'<br />Done!';
    ?>


    This should only fill in the captions that are empty.
    Thankful People: rendeto, carminejg3
    • CommentAuthorElkana
    • CommentTimeJul 7th 2009
     
    Wow, this is really really great! It helped me so much! I've used the latest code (above this post) and this is soooooooo great! :D