biber Posted September 21, 2018 Share Posted September 21, 2018 Hi, I'm running the site http://malabu.de with a number of picture galleries. I can edit all pages (add and remove pictures, etc.) but the one called "meine Heimat". If I try to edit it, I get an 'Internal Server Error'. This page contains about 300 images, about 500k up to 8M big. Maybe, this is too much, but how can I get rid of the surplus files? I tried to delete some of the images in the directory >site >assets >files >1029, but this did not help. Any ideas? Link to comment Share on other sites More sharing options...
adrian Posted September 21, 2018 Share Posted September 21, 2018 Turn on debug mode to see if you get a more meaningful error. You might be able to increase memory available to PHP to solve it. 1 Link to comment Share on other sites More sharing options...
kongondo Posted September 21, 2018 Share Posted September 21, 2018 1 hour ago, biber said: This page contains about 300 images, about 500k up to 8M big. ?. Yeah. What @adrian said. PHP is most likely running out of memory when ProcessWire tries to create thumbs for those images. Second time round, they should load fine (assuming the thumbs creation finished). Maybe also see if you need to rethink your approach? 300 images on one page, from a UX point of view can be 'not-so-friendly'? 2 Link to comment Share on other sites More sharing options...
biber Posted September 21, 2018 Author Share Posted September 21, 2018 Thanks for Your replys. @adrian: Debug mode is enabled, but none of the logs shows any error. I don't think, I have the right to increase PHP memory. @kongondo: Yes, I think about dividing this page into smaller pieces. But how can I delete an amount of images without the edit-funktion on my backend? As I described, deleting files in the directory >site >assets >files >1029 by FTP does not help. Link to comment Share on other sites More sharing options...
kongondo Posted September 21, 2018 Share Posted September 21, 2018 (edited) Use the API :-). Log in as a super user and throw the following code in some template file and visit a page that uses that template. Delete the code from the template file when done. if($user->isSuperuser()) { $p = $pages->get(1029); // delete some images based on some condition foreach ($p->images as $img) { if($someCondition) continue;# if some condition met, skip deleting this image $p->images->delete($img); } // if deleting all #$p->images->deleteAll(); } Alternatively, use the API to create thumbs in the size ProcessWire would have generated. Edited September 21, 2018 by kongondo 1 Link to comment Share on other sites More sharing options...
biber Posted September 21, 2018 Author Share Posted September 21, 2018 Hi @kongondo, I'm still a beginner, so it takes time to come along. But I will try to use your script tomorrow. Thanks a lot Günter Link to comment Share on other sites More sharing options...
biber Posted September 22, 2018 Author Share Posted September 22, 2018 Hi @kongondo, I have modified your script like this: <?php include('./_head.php'); // include header markup ?> <?php if($user->isSuperuser()) { $p = $pages->get(1029); // delete some images based on some condition foreach ($p->images as $img) { if($img->filesize<300000) continue;# if some condition met, skip deleting this image echo $img->name.'wird gelöscht<br>'; $p->images->delete($img); } // if deleting all #$p->images->deleteAll(); }?> <?php include('./_foot.php'); // include footer markup ?> and saved as a template 'loeschen'. Then I created a Page 'Bilderloeschen' based on this template, but without any further content. If I call this page it shows me "imagename wird gelöscht", but after that all images are still there. Can you tell me, what is missing here? Thank you in advance Günter Link to comment Share on other sites More sharing options...
kongondo Posted September 22, 2018 Share Posted September 22, 2018 (edited) Oops, my bad. You need to save the page as well. Do this after and outside the foreach. So $p->save() as shown below. <?php include('./_head.php'); // include header markup ?> <?php if($user->isSuperuser()) { $p = $pages->get(1029); // delete some images based on some condition foreach ($p->images as $img) { if($img->filesize<300000) continue;# if some condition met, skip deleting this image echo $img->name.'wird gelöscht<br>'; $p->images->delete($img); } // set page output formatting off first $p->of(false); // save page 1029 to effect changes $p->save(); // if deleting all #$p->images->deleteAll(); } ?> <?php include('./_foot.php'); // include footer markup ?> note: code edited Edited September 22, 2018 by kongondo corrected silly Saturday night error :-) Link to comment Share on other sites More sharing options...
biber Posted September 22, 2018 Author Share Posted September 22, 2018 save $p seems not to be the correct syntax??? Link to comment Share on other sites More sharing options...
kongondo Posted September 22, 2018 Share Posted September 22, 2018 9 minutes ago, biber said: save $p seems not to be the correct syntax??? ? Does the code not work? Link to comment Share on other sites More sharing options...
kongondo Posted September 22, 2018 Share Posted September 22, 2018 (edited) Sorry again. Saturday night! My bad. Call this before delete $p->of(false); I edited my post above as well. Edited September 22, 2018 by kongondo Link to comment Share on other sites More sharing options...
biber Posted September 22, 2018 Author Share Posted September 22, 2018 Hi @kongondo, now the images are deleted, but the page 'meine Heimat' still shows the name of the deleted images. Link to comment Share on other sites More sharing options...
kongondo Posted September 22, 2018 Share Posted September 22, 2018 (edited) 3 minutes ago, biber said: Hi @kongondo, now the images are deleted, but the page 'meine Heimat' still shows the name of the deleted images. I've noticed that as well. I think that's weird. Maybe a bug or a cache issue in ProcessWire? I've not seen this behaviour before. I've been able to get rid of the 'blank references to deleted images' by deleting them in the page editor. Edited September 22, 2018 by kongondo Link to comment Share on other sites More sharing options...
biber Posted September 22, 2018 Author Share Posted September 22, 2018 maybe, its a problem with the image-extra module? Link to comment Share on other sites More sharing options...
kongondo Posted September 22, 2018 Share Posted September 22, 2018 I'm using the core ProcessWire image field, so no. All, Anyone knows what's going on here? Link to comment Share on other sites More sharing options...
bernhard Posted September 23, 2018 Share Posted September 23, 2018 12 hours ago, biber said: ...saved as a template 'loeschen'. Then I created a Page 'Bilderloeschen' based on this template, but without any further content. If I call this page it shows me "imagename wird gelöscht", but after that all images are still there. Can you tell me, what is missing here? I'd recommend you install Adrian's awesome tracy debugger module. It helps a lot in all kind of situations - maybe also in your current one. It might throw a more meaningful error. Or at least it makes it very easy and comfortable to run some code snippets. The panel is called "console". You can just paste in some code, run it, dump variables, log messages etc. Did you try to rename your 1029 folder via FTP to 1029_bak and see what happens? Can you move your site to another server and see if that makes a difference? Link to comment Share on other sites More sharing options...
biber Posted September 23, 2018 Author Share Posted September 23, 2018 I deleted an amount of files in the database (via phpMyAdmin). After that I was able to edit the page again. Thank you for your help, I am still learning ... Now I created some subpages to avoid this trouble again. Is there an easy way to move some images from the parent page to the subpages (preferred complete with title, description, etc.) Link to comment Share on other sites More sharing options...
adrian Posted September 23, 2018 Share Posted September 23, 2018 3 minutes ago, biber said: s there an easy way to move some images from the parent page to the subpages (preferred complete with title, description, etc.) Try this out https://github.com/mr-fan/AutoImagePages/blob/master/AutoImagePages.module Link to comment Share on other sites More sharing options...
biber Posted September 23, 2018 Author Share Posted September 23, 2018 Hi @adrian, thanks for your fast reply. I will try out this in the next days. Tonight it's time for bed. Link to comment Share on other sites More sharing options...
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