Creating page for every image uploaded?

Recommended Posts

Oh don't know why but the first version get me a 0 value and get a mysql error for every double image....the script stucks and don't skip.

If i replaced $page with (wire('pages') it works. (searched the forums a lot for posible problems and made some short trial and error and output the get results...)

And yes in my test i wanna check all pages/images - while user could should not upload a image to different albums.

If user could do that and use drag and drop in the pagetree ->same image in cat A d&d to cat B -> error on the same name under the same parent...?

Share this post

Link to post
Share on other sites

Hi @adrian, coming to this script very very late :D

Couple of questions, firstly, is it still usable in PW3? Secondly, I've tried implementing it but not entirely sure where the new pages are supposed to be created?

Is this reliant on having a template "family" relationship? I have set up a page for the "Images" template and allowed only "image" template as children but not sure if I'm missing something out of the process? Thanks

Share this post

Link to post
Share on other sites

Hey @onjegolders - I just tested @mr-fan's version of this script (which makes it a configurable module) and it works fine for me in PW3. The new page are created as direct children of the page where the bulk images are uploaded. 

The only thing I noticed that seemed a little weird is that if no description for an image was entered, the child page title used the name of the image directly including the file extension. I have created a PR which improves this:

Until that is accepted, please check out my fork:

  • Like 1

Share this post

Link to post
Share on other sites
Just now, onjegolders said:

Just out of interest do and family settings need to be set on the images/image templates?

Nope - you just select the template of the parent page and the template that you want to use for the child pages from the module config settings. It should be pretty obvious once you start with it.

Share this post

Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By rolisx
      Hi all
      I have a problem here. I created a gallery with 240 pictures. Created an images field with no maximum amount (0). Unfortunately, only 98 of the 240 images show on the website. Any idea what I possibly could have done wrong? Thanks for your help!
      <?php foreach ($page->images as $image) { $options = array( 'quality' => 90, 'upscaling' => false ); $thumb = $image->size(250, 250, $options); ?> <div class="col-xl-2 col-lg-3 col-md-4 col-sm-6 col-6 foto"> <a href="<?= $image->url ?>" data-lightbox="lightbox" > <img src="<?= $thumb->url ?>" alt="" > </a> </div> <?php } ?>  
    • By quickjeff
      Hi Guys,
      I am running a page template that contains a filter form that allows users to display results based on number of  comments. 
      Here is what I am thinking about doing: 
      -add new field called total_comments 
      -somehow populate this field every time a new comment is added or removed by admin with count($page->comments)
      -use form filter to display results that the selector form has found.
      Example: $selector = “total_comments>=$q”; 
      My question to everyone: Is this a good approach? If so how do I get another field to update based on the comment module adding or removing a comment? 
    • By Marco Angeli
      Hi there,
      I migrated my site from dev to live server. Copied all files in the new location, transferred MySQL db from dev to live.
      The site works properly, but the images not.
      Even the processwire logo in control panel is not visible: is it something related with files permissions?
      Is there an easy way to solve this issue?
      EDIT: if I update a page via control panel, adding a new image, the thumbnail is blank...
    • By derelektrischemoench
      Hi guys,
      I'm trying to resize images which I query through getRandom(). I can't seem to get it right though. What I have so far is:
      $randomImage = $pages->get($targetPageId)->images->getRandom() Which returns an image, albeit in original resolution. I assumed I should be able to call resize() on the image like so:
      $randomImage = $pages->get($targetPageId)->images->getRandom()->width(400) Which unfortunately gives me an exception. I assume this is because getRandom() might not return an image but something else(?).
      So how would I do this correctly?
    • By dragan
      All of a sudden image-upload seems broken. No matter if I want to upload one single image or several images.
      Chrome console says:
      Uncaught SyntaxError: Unexpected token in JSON at position 414 at JSON.parse (<anonymous>) at Function.parseJSON (JqueryCore.js?v=1535110864:2) at XMLHttpRequest.<anonymous> (InputfieldImage.js?v=122-1535110864:1973) // File uploaded: called for each file xhr.addEventListener("load", function() { xhr.getAllResponseHeaders(); var response = $.parseJSON(xhr.responseText); // line 1973 The spinning animation GIF keeps on spinning forever...
      I thought I have seen a forum thread about such an error, but I can't find it anymore.
      If I inspect;id=11203&amp;InputfieldFileAjax=1 I only see headers, no content.
      content-type: application/octet-stream (in request header)
      in response headers:
      x-tracy-ajax: 1
      x-xss-protection: 1; mode=block
      Does anyone know what could cause this?
      PW 3.0.111 / PHP 7.2.8