recreate all images for all table uploads
7 posts by 2 authors in: Forums > CMS Builder
Last Post: Yesterday at 3:37pm (RSS)
By kitsguru - December 17
I am looking for a plugin to iterate over each table, find any upload fields and recreate the images for each thumb. I can write one if it does not exist, but some direction on how the recreate works would be helpful.
I want to be able to select a single table or all and then process the table(s) for each size. I looked through the upload_functions but could not figure out where to start.
By Dave - Wednesday at 9:29am
Hi Jeff,
Try: CMS Setup >Database Editor > Your Menu > Your Upload Field > Modify > Thumbnail Settings > "recreate" link. That should automatically recreate all your thumbnails.
Let me know if that works for you. Thanks!
interactivetools.com
Nope, that does not work for me. That is what I do now. It is a manual process that only does a single thumbnail at a time. I have 20 tables with several image upload fields (used for different purposes) across 50 client sites. Doing a site at a time would only take 20 clicks, whereas doing it manually takes (50 sites x20 tables x4 thumbs) a minimum of 4000 clicks, assuming only one upload field per table, not including navigating to each table and each upload field in the database editor.
I want to write a plugin to automate it across all selected tables and uploads with one command. Similar to how the permalinks->update table works.
The plugin would work like so:
- Display a list of all tables that have 'upload' fields
- Select one or more tables
- Iterate over each table
- iterate over each 'upload' field
- iterate over each thumbnail
- recreate each thumbnail (requires rebuilding each image, and updating uploads table)
- iterate over each 'upload' field
I'm just unsure where to start with triggering the recreate. The first three steps are easy to 3.1.1; I'm stuck on 3.1.2.
I haven't figured out which function to call or if I need to call a Javascript function. Reverse engineering the whole process to find the entry point takes too much time, so a little guidance is all I need.
By Dave - Thursday at 12:26pm
Hi Jeff,
Sure, here's where the relevant code is:
- recreateThumbnails(num) in /cmsb/lib/menus/database/editField_functions.js
- recreateThumbnails() in /cmsb/lib/upload_functions.php
- And the code that triggers it is in /cmsb/lib/menus/database/editField.php
<a href="#" onclick="recreateThumbnails('<?php echo $num ?>'); return false;" id="recreateThumbnailsLink<?php echo $num ?>"><?php echo t('recreate'); ?></a>
<span id="recreateThumbnailsStatus<?php echo $num ?>"></span>
If you could piggyback on that code, it might be easiest. Through the web, you could loop over your tables and create an iframe with each upload field that triggered the start of the js process. Or, from the command line you could call the PHP recreateThumbnails() directly and fake the $_REQUEST values to make it do what you want.
Hope that helps!
interactivetools.com
Perfect, I will dig into it a bit deeper over the next 2 weeks
I was researching the iframe idea and looked through several plugins. However, I am unsure what you mean or why I might need an iframe.
Could you provide a bit more detail?
Thanks.
By Dave - Yesterday at 3:37pm
HI Jeff,
I thought we could make use of the CMSB functionality but taking a closer look it didn't seem feasible.
Try the attached command line script, if you can get it working, and then have it loop over all your tables, fields and thumb numbers, it might do what you need.
interactivetools.com