Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
We have 3 presets on the site:
preset_A
preset_A_horizontal
preset_A_vertical
in preset_A, the only action configured is the aspect switcher.
When preset_A settings are edited, all cached images under preset_A are flushed.
But they should also be flushed when preset_A_horizontal or preset_A_vertical edited.
Comments
Comment #1
dman CreditAttribution: dman commentedGood point! I hadn't thought of that.
Comment #2
dman CreditAttribution: dman commentedI've tried looking at that ... the code would need to be quite custom - more custom than imagecache currently allows.
There's no hook or trigger to use to send to the parent presets.
I'll just have to leave that as a known limitation.
Comment #3
fietserwinD7 does:
- provide a hook when saving image styles: hook_image_style_save
- provide an API function to flush a style: image_style_flush()
So easy to solve in D7. Should also be solved for the subroutine effect from custom actions. For D6 this will be a won't fix anymore: there is a workaround by manually flushing a preset (not existing anymore in D7...) and changing styles is not that common, it is more a 1-time action.
Comment #4
fietserwinTurned out that I needed to implement hook_image_style_flush(). hook_image_style_save() is not called at all moments we would want to flush other styles as well.
@dman: can you look into the @todo's and questions (and answer them) I added to canvasactions.inc?
Comment #5
dman CreditAttribution: dman commentedIn testing from the investigation below, it looks like the presets are getting flushed correctly now. That's cool.
That's what the extra ratio adjustment is for.
If given an image 100x100, and you set the ratio adjustment to 0.9, squarish images will tend to be treated as portrait.
Set it to 0.75, and everything more upright than a 4:3 landscape will be treated as a portrait.
(Actually, I found a bug there where the ratio was inexplicably cast to an int. Fixing that now)
If you really really need to have three choices, there are instructions for chaining two effects in the file help/aspect_switcher.html
The overload that providing and explaining all the options would put on the UI was really difficult, and greater and more flexible and unpredictable results could be built from allowing chaining, so that's there. This way also allows you to define the margin of error - how square is mostly square - rather than pixel perfect.
An oversight if anything. I don't think allowing nothing was intentional at the time. It's unexpected that
would give us a "none" option, so may have been a FAPI update that introduced that.
However, yeah, there is no reason why we can't just allow none and return immediately.
I've tested that, it works. Added a note to the form to explain that it's allowed and nothing happens.
Maybe an errant search & replace on upgrade. Yes that should have been checking if the style still existed.
Fixing that meant that ^ could work as described.
Um.. it tried to pass them through.
That was copied code from the original internals as there was no way (at the time) to invoke a process cleanly. the old action harness used to do that before calling the scale/crop action setc, so I had to also. If the parameters for that have changed (it only knows about the xoffset, etc that the common core processes used), then it may well need reviewing.
Looks like now that image_effect_apply() is available (wasn't in D6) we don't need to and shouldn't do that ourselves any more.
.. Yeah, that just can be deleted. I can't come up with a case where it's needed any more.
. done.
... Man I find hook_image_dimensions annoying...
I've added the passthrough as needed now. Should work. *sigh*
OK, so that's all addressed. Pushing it up now.
Tested only on aspect-switcher + core scale/crop and imagecache_actions define_canvas so far. May be side effects elsewhere? Should be fine though.