Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

CRITICAL: Missing / Disappearing Images


Reply

27 Posts   4498 Views

Avatar
Devlin

7 February 2014 at 10:27pm Community Member, 215 Posts

Don't use FlushGeneratedImageTask. It will "Remove all cached/generated images created as the result of an image manipulation" and "Actually clear out all the images".

All resized images inside HTMLEditors will be lost, because the path to the resized image is hardcoded in the image tag.

e.g.:
- You have "assets/Uploads/_resampled/ResizedImage200268-02.jpg" somewhere
- FlushGeneratedImageTask will remove all cached images
- "assets/Uploads/_resampled/ResizedImage200268-02.jpg" doesnt exists anymore
- edit "assets/Uploads/_resampled/ResizedImage200268-02.jpg" to "assets/Uploads/02.jpg" and save the DataObject
- a new "assets/Uploads/_resampled/ResizedImage200268-02.jpg" will be generated.

Avatar
flipsidenz

19 February 2014 at 8:36am (Last edited: 19 February 2014 8:44am), Community Member, 49 Posts

Hmmm, that's a bit of an oversight....

Okay, how about this slight change of tack. When I was calling "FlushGeneratedImagesTask", I was only concerned with flushing the resampled folder of a specific directory within "assets/".

Is there a way to flush all generated images within a certain folder only?

Avatar
Devlin

19 February 2014 at 9:52pm Community Member, 215 Posts

Sure. Write your own FlushGeneratedImagesTask?

Anyhow, cached images will be deleted if its original image get deleted. So there is really no good reason to use this task other than to have a clean state for development purposes.

@see
Image->onBeforeDelete()
Image->deleteFormattedImages()