Issue with image assets created on save but not on publish

Silverstripe Version:
PHP: 7.3.6
Silverstripe: 4.3
nomidi/silverstripe-webp-image: dev-master
Dev/build and flush=1 done

Question:

If admin creates a page and clicks publish , everything works correctly.
resized JPG’s and WebP’s are created in the hashed assets folder.

If admin creates page and clicks save .
resized JPG’s are created in the hashed assets folder that work fine.
resized WebP’s are created but the content is blank.

if the page is then published at a later date the webp’s remain blank the assets are not regenerated.

if all resized images are deleted after the page has been published, either manually or using flush. When the page is revisited both JPG and WebP assets are created successfully and everything works fine.

why would save be causing the asset generation to fail?

### Template

Page templates have image class added with following:

`private static $has_one = array('heroimage' => Image::class)`
`private static $owns = ['heroimage']`

Images are then scaled on page for different viewports e.g.

`$heroimage.ScaleWidth(1680)`

above isn’t strictly true, i’ve updated with the full details on the plugin repo

essentially it looks like the plugin isn’t created a protected asset.

if anyone has any experience with this I would appreciate a pointer in the right direction as I would like to do a pull request for this.

is there a helper in silverstripe that will tell me the assets protected folder? or write a file to the protected location?

or do i need to do the following?

  1. check config file to see if protected location is changed
  2. hash original image file, and truncate first number of characters to get hash folder name.
  3. write new file to ./protected/hash or other location if config is different.
  4. change permissions on new file?

when the file is then finally published is the entire folder then just moved to the public/assets/hash location or do i need to hook into something when the files are published?