Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
This patch gently introduces Views-style exporting of imagecache presets. Exported presets can be provided in code by modules through hook_imagecache_presets(). Presets in code are collected when the imagecache preset cache is built. The patch distinguishes between presets in the database and presets in code by assigning a module-delta string identifier to presets from code.
TODO:
- Implement imagecache preset importing
- Implement imagecache preset user-overrides (like Views)
Comment | File | Size | Author |
---|---|---|---|
#17 | imagecache_default_presets_feb9.patch.txt | 14.77 KB | yhahn |
#10 | imagecache_default_presets_feb1.patch.txt | 13.73 KB | yhahn |
#9 | imagecache_default_presets.patch.txt | 12.1 KB | yhahn |
imagecache_presets.patch | 10.32 KB | yhahn |
Comments
Comment #1
moshe weitzman CreditAttribution: moshe weitzman commentedLovely. Thanks.
Comment #2
dopry CreditAttribution: dopry commentedI love the concept, but won't be adding new features to 2.0.
Comment #3
dopry CreditAttribution: dopry commentedI've finally had a chance to review this patch. It's really nice. The only fault I find is the way module defined presets are identified... I'd prefer they had a system flag in the presets table. Would you be up to making the alteration?
Comment #4
yhahn CreditAttribution: yhahn commentedNot a problem dopry.
Incidentally, I may be poking around and looking for a way to generalize the Milesian import/export/override/disable paradigm -- a "structures" module or API that provides a simple way for module developers to quickly implement the Views-style framework would be very handy (and reduce a lot of code duplication across modules).
Comment #5
drewish CreditAttribution: drewish commentedyhahn, Any chance of getting you re-roll this against HEAD? I'd love to get it in.
Comment #6
laken CreditAttribution: laken commented+1 for this! Anyone have a status?
Comment #7
greg.harveyLikewise! Just wondering how to handle the installation of some imagecache presets in the hook_install() of my module - this would rock my world! =)
Comment #8
yhahn CreditAttribution: yhahn commentedJust a quick update -- this hasn't fallen off my radar entirely : )
I'll be returning to this, but probably with an even more views-ish approach for better caching/performance and simpler code.
Comment #9
yhahn CreditAttribution: yhahn commentedHere is the latest iteration of this patch -- it makes a few changes from the D5 version:
['storage']
key at the time of preset caching (seeimagecache_presets()
)Patched against checkout of CVS imagecache on Jan 30, 2009.
Comment #10
yhahn CreditAttribution: yhahn commentedOne more iteration -- makes adjustments to the actions form theme function to respect default presets.
Comment #11
greg.harveyAlrighty, this is late in the day, so you might want me to raise a separate feature request, but it falls in with the above. Are you planning to provide a hook so other modules can embed presets in their code, a la Views with hook_views_default_views (or whatever it's called).
That would be awesome! For me, as a module developer, that would be a real killer feature ... and with the export and import code written you're 80% there. =)
Comment #12
yhahn CreditAttribution: yhahn commentedHey greg,
This is actually already implemented in the code above:
This allows you to use
hook_imagecache_default_presets()
where your module can provide an array of exported imagecache presets andhook_imagecache_default_presets_alter()
if for some reason you are springboarding off of another module's presets and want to modify them.Comment #13
greg.harveyAwesome! Sorry for not checking properly before posting. I'll see if I get chance to review your patch on Wednesday. Very exciting! Great additions! =)
Comment #14
drewish CreditAttribution: drewish commentedwow, this looks great. i'm going to roll a release right now to get some bug fixes out but i definitely want this in the next one.
Comment #15
drewish CreditAttribution: drewish commentedyhahn, I just added a imagecache.api.php to HEAD as a place to document the module's hooks. We should document the new hook_imagecache_default_presets() there.
Comment #16
q0rban CreditAttribution: q0rban commentedWow, this is awesome, no more adding presets manually on hook_install! Haven't tested it, but if it does everything described above it certainly gets my vote...
Comment #17
yhahn CreditAttribution: yhahn commentedPatch updated to apply cleanly to imagecache d6 HEAD. I've also added
hook_imagecache_default_presets()
toimagecache.api.php
.Comment #18
drewish CreditAttribution: drewish commentedgreat, thanks for sticking with this. committed to HEAD. going to roll a new release in a few minutes.
Comment #19
yhahn CreditAttribution: yhahn commentedThanks drewish!
Comment #21
Alan D. CreditAttribution: Alan D. commentedThis is a very cool feature. It has become the default way we define presets for clients as they can't screw things up! Nice work.
Any chances for a 5 backport sometime? I know Drupal 5 is almost dead, but we have a few clients where upgrading to Drupal 6 is currently not an option.
Thank
Comment #22
NancyDruOkay, so I'm stupid. I exported the code and tried in both my main module file and .install file. How does it get invoked to define the preset?
The docs at http://drupal.org/node/558664 don't seem to be much help here.
Comment #23
NancyDruI finally figured it out. The export does not include a
return $presets;
and it should. I also had to move the hook_install into the main module to make it work (probably a path problem).And now that I look at it, is it possible to change the export so that it can be more properly copied into a module?
A) it is not indented
B) there are array openings where the word "array" is on the next line (e.g. on "data")
Comment #24
lpalgarvio CreditAttribution: lpalgarvio commentednice idea. +1.
subscribing, keep up the work
Comment #25
fizk CreditAttribution: fizk commentedMarking as ImageCache 3.x Todo.