Voyager: how can delete old photo when update image post ?

Created on 3 Jun 2017  路  4Comments  路  Source: the-control-group/voyager

Hi guys
why after change post image the old image in storage file will not be delete !!!!!!
That's big bug for increase memory disk !

bug

Most helpful comment

Hi.
This is a bug indeed.

There are 2 more bugs related:

  1. if we delete a post, all related images are not being removed from the server (PR #1284 sent)
  2. button for delete image is missing

Thanks for the tip

All 4 comments

Hi.
This is a bug indeed.

There are 2 more bugs related:

  1. if we delete a post, all related images are not being removed from the server (PR #1284 sent)
  2. button for delete image is missing

Thanks for the tip

I believe the above issues have been resolved in other PRs. Closing for now. If this is still an issue after the 1.0 release, please open a new issue

use mutators in case you want to remove old image after update;
f.e.

   public function setAvatarUrlAttribute($value)
    {
        // in case of edit and send new avatar image
        if (strtolower(request()->method()) === 'put' && $value !== $this->avatar_url) {
            Storage::disk('public')->delete($this->avatar_url);
        }

        $this->attributes['avatar_url'] = $value;
        return $this->attributes['avatar_url'];
    }

Please don't comment on issues that have been closed for so long (3 years in this case). It was for a VASTLY different version of Voyager

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iwasherefirst2 picture iwasherefirst2  路  3Comments

craigb88 picture craigb88  路  3Comments

raoasifraza1 picture raoasifraza1  路  3Comments

vaggelis2018 picture vaggelis2018  路  3Comments

abacram picture abacram  路  3Comments