Jump to content

Cannot edit one of my pages


biber
 Share

Recommended Posts

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

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'?

  • Like 2
Link to comment
Share on other sites

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

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 by kongondo
  • Like 1
Link to comment
Share on other sites

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

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 by kongondo
corrected silly Saturday night error :-)
Link to comment
Share on other sites

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 by kongondo
Link to comment
Share on other sites

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

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

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
 Share

  • Recently Browsing   0 members

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