Jump to content

Working with PageImages creates unwanted copies of images


sujag
 Share

Recommended Posts

Most probably due to a lack of understanding of basic concepts I just produced a template that led to an explosion of disk space usage for the site.

What I need(ed):

Reusing images of certain pages for a gallery of other pages. I have a page with events that are linked to locations and want to show the pageImages of the eventPages and those Location-Pages in a gallery on the eventPages

What I did:

created a PageImages-Array from current (event) page

$galleryfrompage = $page->images->findTag('galerie');
$gallery = $galleryfrompage;

getting certain Images from connected location page

$locImages = $loc->images->findTag('galerie');

adding $locImages to $gallery

foreach ($locImages as $li) {
    if ($li != $introImg) {
        $gallery->add($li);
    }}

what happened:

with every visit of the event page a new copy of the images from the location page was copied to the event page

 

I now try a new attempt without pageimages but wanted to ask, if this behaviour would have been obvious for you.

Link to comment
Share on other sites

After adding an initial

$gallery = new WireArray();

everything works as expected.

Irritating with my first attempt was, that the  copies of the image files where only added to the respective folder in assets/files but not to the database and the page images. At least this seems a little buggy to me.

Link to comment
Share on other sites

1 hour ago, sujag said:

Irritating with my first attempt was, that the  copies of the image files where only added to the respective folder in assets/files but not to the database and the page images. At least this seems a little buggy to me.

it's probably because add() just adds, it doesn't save().

  • Like 1
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...