heldercervantes Posted May 2, 2016 Posted May 2, 2016 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
netcarver Posted May 2, 2016 Posted May 2, 2016 @heldercervantes For images, look at removeAll() for getting rid of everything in the field or just removeVariations() to kill off the size variations. 3
heldercervantes Posted May 2, 2016 Author Posted May 2, 2016 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?
heldercervantes Posted May 2, 2016 Author Posted May 2, 2016 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.
kongondo Posted May 2, 2016 Posted May 2, 2016 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 1
heldercervantes Posted May 3, 2016 Author Posted May 3, 2016 Well I DID say I'd probably feel dumb in the end Forgot to save 2
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now