Maintenance task to get rid of .jpg in picture title
pelle
![]()
Joined: 2004-12-10
Posts: 389 |
![]() |
|||
I usually dont rename the title of photos in my Gallery. This results in items with for instance titles such as IMG_0000.jpg and often with the same description (especially if you upload with Gallery Remote). With G1 these titles became 'IMG 0000' which to me looks nicer. Therefor, I've made a System Maintenance script which removes the filename extension and replaces underscores with spaces in the title for photo and movie items. Also, it deletes the description/summary if they only contain the filename. I find this very useful for pictures I added with Gallery Remote or pictures migrated from G1. Download the file below and place it in gallery2/modules/core/classes. For it to be recogniced you need run this SQL statement (might need to flush the database cashe - I'm not sure)
|
||||
Posts: 8601
pelle, nice.. how about putting this in its own module and register the task automatically when the module activates?
Posts: 389
Sure I could, is this something of interest for cvs?
Posts: 7994
We might want to make a catch-all module for things like this. Like a "Maintenance" module that has a selection of 10 or 15 common tasks that people might want to do. Most folks probably don't need it, but it saves us from having to write a new module every time we want a new maintenance task. That would probably be a fine thing to have in CVS.
On another note, perhaps we should strip the .jpg tag (and other known file tags) off of the title when we upload new files? If we strip that off and convert underscores/dashes to spaces, then most file names will look semi-decent by default.
Posts: 1301
Sounds like a plan to me.
Actually, the more I think about it, the more I like the idea. It would look cleaner, and I'm for anything that makes layouts look less cluttered.
Gaile
Posts: 196
When conducted in a Module you could also rename the Dsc or mvc to something useful like 'Holiday in Europe'. As an Album option/action.
Posts: 7994
I added a G2 task for this.
Posts: 22
maybe you can add a ability to rename all the items in an albul to say "Album Name 001", "Album Name 002" ...
this can be really helpful.
Thanks
Posts: 389
g0d, that sounds like something you would wanna do to a single album, not the whole gallery.
Anyways, here's the module for SanitizeItemCaptions. Other Maintenance tasks can easily be added to the tasks dir, just bump the version number. Perfect if you want to craft your own tasks.
Posts: 22
i agree, this will be done per album basis ... but for the whole album.
I add a lot of images found from the web to my gallery, and over tim the filenames become a lot wierd. Thats the reason for this.
Can your module do such a thing ?
Posts: 8601
g0d, it won't do exactly what you want, but you may be able to modify it to do what you want.
Posts: 22
i will try that ... and will upload the module if i achieve some success.
Posts: 100
SQL statement produces the following error:
INSERT INTO g2_factorymap VALUES ('MaintenanceTask', 'SanitizeItemCaptionsTask', 'SanitizeItemCaptionsTask', 'modules/core/classes/SanitizeItemCaptionsTask.class', 'core', 'N;', '4');"
MySQL said:
#1146 - Table 'd3v_gala.g2_factorymap' doesn't exist
Even thou the table is physically there. I can see it in PHPmyadmin. Any ideas? Should I drop the tables and try to do re-do them again. Or is there any way to do this without the seperate SQL query.
I installed the filed u provided in 3 different folders just to make sure :x, so that's not it. Thanks for your time.
Posts: 8601
use the later attachment that is a module.. then you don't need any sql.
Posts: 100
muhaha it worked. gg froggy :x thanks mindless
Posts: 16504
Nice work. I like it.
Posts: 16504
FYI, this module doesn't work with some of the latest API changes. I don't know if the only thing that needs to be changed is this
to this
But when I made those changes I was able to reactivate the module and sanitize titles. So it worked. I just don't know if anything else needs to be updated.
Posts: 8601
API version changes are described in a sticky topic in this forum, so you can see if this module does anything that needs updating to conform to current apis.
Posts: 389
Thats all you need to do, update the required API's and you're fine.
Posts: 16504
Thanks guys. I did look through the code and the sticky and thought that was the case. But not being familar with the G2 code I wasn't sure. I am learning more each time I get in there and mess around with something.
Posts: 11
looks like it doesnt work @ my beta4
Gallery-Version = 2.0-beta-4 Kern 0.9.32
PHP-Version = 4.3.8 apache2handler
Webserver = Apache/2.0.50
Datenbank = mysql 4.0.21-Max
Werkzeuge = Gd, ImageMagick, NetPBM, Thumbnail, Exif
Betriebssystem = Linux server2 2.6.8-24.16-smp #1 SMP Thu Jun 2 12:09:57 UTC 2005 i686
Browser = Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
i receive this message:
Warning: Missing argument 1 for run() in /srv/www/htdocs/web25/html/gallery2/modules/maintenance/tasks/SanitizeItemCaptionsTask.class on line 56
Fatal error: Call to a member function on a non-object in /srv/www/htdocs/web25/html/gallery2/modules/maintenance/tasks/SanitizeItemCaptionsTask.class on line 65