Hello,
Some time ago, a guy helped me with a code for Gallery, where it would force Gallery to ignore the picture's filename and created them as aaa_001.jpg, aaa_002.jpg, etc...
I REALLY prefer that it does this.
But, since I upgraded to 2.2, the code does not work anymore.
Below is the old code for 2.1, which worked beautifully!!
Can someone please help me so this works on 2.2??
The file to edit is:
/www/gallery2/modules/core/classes/helpers/GalleryItemHelper_medium.class
function addItemToAlbum($fileName, $itemName, $title, $summary,
$description, $mimeType, $albumId, $symlink=false) {
global $gallery;
--------- THIS PART BELOW WAS THE ADDED CODE ----------------
$platform = $gallery->getPlatform();
list ($base, $extension) = GalleryUtilities::getFileNameComponents($fileName);
$itemName = 'aaa' . $extension;
$title = "";
$summary = "";
$description = "";
Thank you so much!!
Alexandra
Posts: 27300
Have you tried the code? Looking at the older version of /modules/core/classes/helpers/GalleryItemHelper_medium.class this function has not changed much so I can only assume it would still work.
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 143
Hi Dave!!! Yes, of course I tried... and what it does is it makes a HUGE long gibberish filename.
Look at these URLs:
Pic uploaded BEFORE upgrade to 2.2
gallery2/v/buddytaz/taz/aaa_007.html
Pic uploaded AFTER upgrade to 2.2
gallery2/v/buddytaz/taz/aaasite_htdocs_family_gallery2_g2data_tmp_MUF_E5Hh43.html
See?? Instead of a nice short "aaa_007.html"
I get "aaasite_htdocs_family_gallery2_g2data_tmp_MUF_E5Hh43.html"
It's putting the "aaa" in front of the filename, but then adding my whole server path after that and some gibberish "tmp_MUF_E5Hh43"!!
Why??? No idea.. I don't know anything about codes to figure out what could be wrong.
Very strange huh??
Posts: 143
Dave or anybody!!
Can someone please help me resolve this issue?? It might be simple, but I don't know how to write/edit these codes.
Please??
Posts: 180
API info on addItem:
Just a wild guess that maybe $itemName is closer to what you want...it's worth a try at least.
Posts: 143
Thanks Slayergirl, but I'm not sure I understood your response. Is that a code that I need to put in /modules/core/classes/helpers/GalleryItemHelper_medium.class where the old code used to be?
Doesn't look like a code. So I am not sure what am I supposed to do with what you wrote.
The old code that I posted at the top used to work perfectly.... but only on 2.1 and below... So it just needs to be tweaked for 2.2, which I do not know how.
Posts: 27300
If you add a item to gallery with the same filename the title of the item is saved. You can have more than one item in the same album wit the same name.
That said the path name to the item changes if you add items with the same name. EG: You add a item called picture.jpg and you add another item called picture.jpg the second item will now have the same name but the path will be amended with _001 to become picture_001.jpg
The code that does that is in /core/GalleryFileSystemEntityHelper_medium.class. look for:
Dave
_____________________________________________
Blog & G2 |
| floridave - Gallery Team
Posts: 143
Thanks Dave, but that's not what I need because it's not a matter of uploading 2 files with the same name, but keeping it neat and having all filenames short.
So no matter what I upload, whether it's IMG24573.jpg or triptothebeachinthesummer.jpg, it just becomes aaa_003.jpg, aaa_004.jpg, etc...
And I REALLY like that, because I have family members who sometimes contribute to the album, and they sometimes have really stupid filenames or filenames that are too long (don't know why they rename them from the camera's original, but I don't bother arguing with them). So that script used to work wonders and made everything all neat.
Alex
Posts: 143
Hello... I am STILL trying to get this to work... it USED to work, but doesn't anymore with the new version..
Can someone just take a little closer look into it? Please???
Thanks!!
Posts: 143
Solved...
Removed "$base, $extension" next to "list"..
$platform = $gallery->getPlatform();
list ($base, $extension) = GalleryUtilities::getFileNameComponents($fileName);
$itemName = 'aaa' . $extension;
Works perfectly now.