I understand that output formatting has to be off when a page is saved, but it's unexpected that turning it on then off again prevents proper deletion of images.
This is a simplified example for demonstration. In my real scenario I have a good reason for needing to temporarily enable output formatting for the page at saveReady.
$pages->addHookAfter('saveReady', function(HookEvent $event) {
/** @var Page $page */
$page = $event->arguments(0);
if($page->template == 'basic-page') {
// Get current output formatting
$of = $page->of();
// Temporarily set output formatting to true
$page->of(true);
// Do anything that gets the value of an images field
$images = $page->images;
// Restore the original output formatting
$page->of($of);
}
});
Problem with image deletion:

I understand that output formatting has to be off when a page is saved, but it's unexpected that turning it on then off again prevents proper deletion of images.
This is a simplified example for demonstration. In my real scenario I have a good reason for needing to temporarily enable output formatting for the page at saveReady.
Problem with image deletion: