Jump to content

Recommended Posts

Posted

Hi.

I'll probably feel dumb when you give me the solution, but I can't find this anywhere.

I want to delete all images and resized variants from a page, keeping the page. How is this done via API?

thanks,

H

Posted

Doesn't seem to do anything.

I'm trying $page->images->removeAll()

I'm also finding junk files in an example page that aren't in the images field. I'm thinking these are a result of interrupted saves or something like that. Isn't there a way to just delete the assets directory for the page?

Posted

With a little help from another post from Ryan, I got this:

$dir = $page->filesManager->path;
$dit = new DirectoryIterator($dir);
foreach($dit as $df) {
  unlink($df->getPathname());
}
rmdir($dir);
$pages->uncache($page);

And away go all assets from said page.

Posted

Doesn't seem to do anything.

I'm trying $page->images->removeAll()

I'm also finding junk files in an example page that aren't in the images field. I'm thinking these are a result of interrupted saves or something like that. Isn't there a way to just delete the assets directory for the page?

I bet you forgot to save  :)  ;)

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...