The old 'flush' feature was removed from the image module
here is a previous discussion: http://drupal.org/node/371374#comment-1793682
We were just discussing this and came up with some arguments for providing the 'flush feature'
the argument was that people were not using flush, and that resaving the setting would trigger the images to be regenerated.
However, there are some use cases for this feature.
* you programmatically create image style settings (For example, you have a module that has all of the settings that you usually use for all of your drupal websites. one day, you change all of the settings. you would like to update all of the images. a button would be convenient for this.) In this case, users would not want to override the settings in the system, and the image setting would not be rebuilt. This would require module developers to add a hook that would update the images, which is kind of clunky.
* This could interfere with features exports...if you are using a feature hosted by someone else and you have updated, it would be good to have all the images to be rebuilt.
* You switch image toolkits and would like to trigger all of the images to be updated.
Some suggestions of ways to add this feature back in:
* add the button back in - either where the feature used to be, or as part of 'devel' or in a special image style administration settings tab/page - if the concern is that the 'flush/refresh' button is non-intuitive to users only using the GUI.
* add button back in, and rename 'flush' to 'refresh images' or 'update images' or 'resize all images'
* provide a very simple hook that could be added to modules on install
Comment | File | Size | Author |
---|---|---|---|
#61 | flush-700696-61.patch | 6.31 KB | claudiu.cristea |
#61 | interdiff.txt | 757 bytes | claudiu.cristea |
#58 | flush-700696-58.patch | 6.35 KB | claudiu.cristea |
#58 | interdiff.txt | 758 bytes | claudiu.cristea |
#52 | flush-700696-52.patch | 6.31 KB | claudiu.cristea |
Comments
Comment #1
chachasikes CreditAttribution: chachasikes commentedThought of another use case for 'flush'
Say you have several development environments for 1 drupal site (production/dev/local) - someone changes the database settings for the image styles, you update the database. All your images will be out of date unless you can clear them out. There is no need to re-save them, because your database is already correct.
Comment #2
pyrollo CreditAttribution: pyrollo commentedAnother need for image flush :
When you disable or re-enable a module that provides effects used in styles, images should be recomputed.
Such modules should be able to call a function in hook_enable() and hook_disable().
A kind of image_all_styles_flush, doing exactly the same job as image_style_flush but for all styles would work.
Comment #3
pyrollo CreditAttribution: pyrollo commentedHere is a patch that adds a image_all_styles_flush to image.module.
This patch does not bring any visible change, it only makes this function available for other modules.
I am in need for that function in order to have IM_Raw module fully working on Drupal 7 (see #989520: ImageMagick raw action for Drupal 7).
Comment #4
adrinux CreditAttribution: adrinux commentedI'm really missing this feature too. Sometimes styles seem to get stuck, re-saving a style doesn't cause a flush, switching to a different image style and back doesn't cause a flush. Just end up with broken styles.
Comment #5
idflood CreditAttribution: idflood commentedsubscribing ( it may also be useful when changing the quality of the generated images )
Comment #6
moshe weitzman CreditAttribution: moshe weitzman commentedIn case folks are desperate, there is a core drush 4 command that flushes.
Comment #7
vasna sdoeung CreditAttribution: vasna sdoeung commentedsub
Comment #8
sun+1. New features go into latest core first though. And obviously, this patch needs work.
Comment #9
hunthunthunt CreditAttribution: hunthunthunt commented+1: this is a much missed feature!
My interim fix is to add the following to my themes template.php
Hope this helps ;)
Comment #10
willvincent CreditAttribution: willvincent commentedHere's a patch (older p0 format, not the git p1 format) for 7.x that adds the flush operation back into the list of operations for image styles.
I'm sure this probably won't be rolled into the core module, but if anyone needs/wants this this should do the job for you.
Apply patch, then clear cache since this adds a menu path.
Comment #12
willvincent CreditAttribution: willvincent commentedUpdated path for files to be patched, hopefully this one will pass testing. The previous patch in #10 applied just fine if applied from within the modules/image directory.
This one should apply from the drupal docroot, which I think is what the testbot expects.
Changing back to 7.x-dev also for the testbot.
Comment #14
willvincent CreditAttribution: willvincent commentedAck! Apparently the testbot doesn't support p0 patches anymore. here's a p1 version of the same patch.
Comment #15
willvincent CreditAttribution: willvincent commentedChanging issue back to D8.
Comment #16
jenlamptonI have another use case for this. I'm using hook_image_styles_alter() to change the default sizes of these presets for a project I'm working on. The problem is that if anyone views any of the resized images before this module is enabled (or if we decide to change the sizes later on) all the cached images are already created at the previous size, and since we didn't go through the UI to change the size, they don't get rebuilt.
The work-around is to "override" the default provided by the module and then "revert" back. But if we had a "refresh images" button that wouldn't be necessary.
Comments on the patch... (This looks like a patch for D7?)
I can't find the link or button that actually says 'refresh images' or 'update images' or 'resize all images'. I also see a lot of use of the word "Flush" so maybe it wasn't renamed, but I still can't see how to trigger it.
Comment #17
swentel CreditAttribution: swentel commentedPatch against new core structure.
Also, it adds a 'flush' operation link on the image styles overview screen.
Comment #18
to.stepan.kuzmin@gmail.com CreditAttribution: to.stepan.kuzmin@gmail.com commentedI was writing module that similar to that issue — imagestyleflush (http://drupal.org/sandbox/StepanKuzmin/1454096, applyed for full project at http://drupal.org/node/1454106).
Here is patch, that brings this module functionality to Drupal 7.x
Comment #20
swentel CreditAttribution: swentel commentedPatches go to 8.x first.
Comment #22
claudiu.cristeaThis can be achieved by a contrib module like https://drupal.org/project/imagestyleflush. Now, in D8, all you need is to extend the
ImageStyleListController
and provide there the "flush" link. You need also to build a page callback and a route for image style flush.Comment #23
sunI can't see a reason for why someone would/should have to install an additional contrib module to perform this operation.
Comment #24
claudiu.cristeaOK, Sir! Then let's try with this patch :)
interdiff was left out as is not relevant because codebase has changed dramatically.
Comment #25
claudiu.cristeaOh! Forgot that translation manager is already injected and we have
$this->t()
(great!)Comment #26
claudiu.cristeaAnd also a test for new UI parts.
Comment #27
claudiu.cristeaOuch! Forgot an unneeded line inside.
Comment #28
claudiu.cristeaAnd the
image_menu()
entry is senseless. We need only the route.Comment #30
claudiu.cristeaTests are interfering.
Comment #32
claudiu.cristeaAs this turned green, reviews are welcomed.
Comment #33
claudiu.cristeaComment #34
claudiu.cristea@sun, can you provide a review on this? Thank you.
Comment #35
mondrakeI think you can extend EntityConfirmFormBase, and avoid having to manage the ImageStyle entity directly.
When a beginner, I did not understand this. Can we explain a bit more, like "Image derivatives are the result of processing original images through the image styling. These derived images are stored in the file system to speed up further visits. Flushing them now will lead Drupal to recreate the derivatives as they are requested next time."
Also, I'd suggest to keep the "'This action cannot be undone." piece separate for translation. This one can be taken from parent::getDescription i.e.
Comment #36
claudiu.cristeaGreat catch. Thank you! Makes perfectly sense.
Comment #37
mondrakeTested manually.
This patch add a 'Flush' operation to the dropdown in each item on the list of image styles. Clicking on it you're taken to a confirmation form. Confirming the flush, the subdirectory of the 'styles' directory in public://, named after the image style being flushed, is removed from the file system. Clicking again on 'Edit' in the style list, the directory is recreated to produce the sample image on the style preview.
RTBC.
Comment #38
LinL CreditAttribution: LinL commentedNeeds a reroll for the yml file now that #2095121: Ensure every path in routing.yml files has a leading slash is in.
Comment #39
swentel CreditAttribution: swentel commentedComment #40
claudiu.cristeaOh, this was very fast! :)
Comment #41
claudiu.cristeaThe cancel route doesn't need parameters, we are returning to full list.
Comment #43
claudiu.cristeaOh
Comment #44
mondrakeBack to RTBC
Comment #45
Xano#43: flush-700696-43.patch queued for re-testing.
Comment #46
oriol_e9guntag
Comment #47
alexpottThis test would be better if you used clickLink to click on the flush operation on the admin form instead of asserting the href and then just posting the form.
Comment #48
claudiu.cristeaYes, I thought first this approach but clickLink() is taking the link label/text as argument. In that UI all flush labels are the same:
t('Flush')
. The installed profile brings some default image styles, so my test style is not the only one. There's a chance to flush other style. Handling that would get me far from the initial purpose of this test.Comment #49
Dries CreditAttribution: Dries commentedReviewed this patch. I agree this should be part of core, and I think the code looks good. I've some feedback on UX and DX though.
Some of the UI language is a bit scary. For example, "flushing image derivatives for an image style" is very geeky. Can't we write something like "Are you sure you want to apply the updated %name image effect to all existing images?"?
This is super technical. For end-users it doesn't matter that Drupal stores cached copies of processed images. For example, I use Adobe Lightroom to process my photos. It's a tool for professional photographers that handles tens of thousands of photos. I'm sure it uses a ton of caching. However, at no point is that exposed in the UI. I'm not sure that explaining the inner workings of Drupal is useful for the majority of our users.
Outside the scope of this discussion but is there any reason these "empty" {@inheritdoc} comments can't be added by api.module? For me it really negatively affects the readability and DX experience of the code.
Comment #50
yoroy CreditAttribution: yoroy commentedAgreed with the remarks about the descriptions.
1. Are you sure you want to apply the updated %name image effect to all images?
(I removed "existing", because we can't apply the effect to non-existing images :-)
2. I think the suggestion is to leave out this description entirely. Seems like the right idea.
Comment #51
claudiu.cristea@Dries, @yoroy, I agree partially with you. But "flushing" image cache is not an operation provided to regular users. If the site admin has access to this operation, at least he must get some information about what flush means for his site.
Comment #52
claudiu.cristeaOK. Then "This action cannot be undone." is really scary while with this operation (flush) nothing gets lost. That's why I changed the description to not create any unnecessary worry for the user.
Comment #53
mondrakeComments from #46 to #50 have been addressed. Seems safe to set back to RTBC.
Comment #54
StuartJNCC CreditAttribution: StuartJNCC commentedI strongly disagree with @Dries and @yoroy about removing the wording in #50.2. As @claudiu.cristea says, this functionality is aimed at site builders, not end users, so I am not worried about it being a tad techie. If I see "This action cannot be undone." I want to know what is involved! I think the explanation is #50.2 is both appropriate and useful. I too process photographs (although in GIMP not Adobe Lightroom) and, if I am about to commit an edit that will change my image, I want to preview it and know what I am doing before I press the [OK] button!
Comment #55
Dries CreditAttribution: Dries commentedI like the changes in the latest patch, but I'm not sure about the new description. The description was changed from #49.2 to the following:
What are we expecting a site builder to do or take away from this information? What about the following:
"Drupal applies image style to a copy of the original image. This operation does not change the original image but will cause the copies to be recreated."
Assuming that information is correct, the explanation/description seems accessible, yet may provide a bit more explanation per Stuart's suggestion in #54. Thoughts?
Comment #56
claudiu.cristea@Dries,
The only thing that site admin needs to worry about when removing the image cache is that the site may expect some extra-loading when recreating image derivatives. This is the only real reason why we show him the confirmation form instead of performing the operation directly. Maybe we should add some words about that. I'm not a native English speaker, maybe someone else can add few words to explain this?
Comment #57
mondrake+1 to #55
In fact it's the explanation to a normal human being :) of #49.2 (which BTW was my input :))
Comment #58
claudiu.cristeaOK
Comment #59
mondrakeRTBC again.
Comment #60
yoroy CreditAttribution: yoroy commentedThat image styles are applied to copies of the original is already explained in the page help as you can see from the screenshot in #18, not sure it needs to be repeated here.
Two more issues with the latest wording:
- It uses 'Drupal', which we shouldn't do (it complicates distributions, see 'Wording' section in the ui guidelines here:https://drupal.org/node/604342)
- "Drupal applies image style" doesn't sound right, either "Applies image styles" or "Applies an image style".
I think you only need this:
"Flushing does not change the original image but the copies created for this style will be recreated."
As a general note, I disagree with the assumption that site builders are more technical and thus we can use more technical language. Everybody who installs Drupal (think of 1-click installs through hosting providers or Drupal Gardens) is a user/1 with access all areas. We should always strive to use the simplest possible words to describe only that which people need to make their next decision, regardless of assumed role or skill level.
Fewer, simpler words makes Drupal faster (don't make me think!) and more accessible.
Comment #61
claudiu.cristeaAgree with the "Drupal" word removal.
I disagree with your final note. If you give somebody the right/permission to hit the "red button" then he has the right to know. If that user is able to "flush", at least he must be warned about side effects. E.g. (1) he will not lose images (2) copies will be recreated (3) he may experience site loading/slowness, etc.
Changes s/"the original image"/"the original images"
Comment #62
claudiu.cristea@yoroy, Can you re-RTBC please if this version is OK? As functionality it was RTBC several times.
Comment #63
yoroy CreditAttribution: yoroy commentedOk. From 260 to 100 characters in that description is a good thing :-)
Comment #64
alexpottCommitted 3bcad72 and pushed to 8.x. Thanks!