Jump to content
Jay D

How to create image variations?

Recommended Posts

Hi all, 

 

I am new to PW, and so far I am really digging it. Longtime WP and Laravel user, so PW seems very clean and efficient.

 

One issue I am having a hard time discovering is; When I create an image array, I want to create permanent thumbnails that, are not created at time of page load. I see I have a *0x250.jpg file, but not sure where I can change the settings to make a 250x200 type image. 

 

Thank you in advance, I have been searching, and it seems most forums point to temp resizing.

 

Jay

Share this post


Link to post
Share on other sites
Posted (edited)
1 hour ago, Jay D said:

I am new to PW, and so far I am really digging it.

Welcome to the forums and ProcessWire 🙂.

1 hour ago, Jay D said:

I want to create permanent thumbnails that, are not created at time of page load.

ProcessWire does this only once. So, the next time, it will just load the thumbnail you requested, hence it is permanent unless you delete it. 

1 hour ago, Jay D said:

I see I have a *0x250.jpg file,

I think you mean 0x260. That is generated automatically by ProcessWire for backend use. You can create your own (other sizes) like shown below. This code goes into your template file.

// Example of outputting a thumbnail gallery of Pageimage objects
foreach($page->images as $image) {
  // $image and $thumb are both Pageimage objects
  $thumb = $image->size(250, 200);// width x height
  echo "<a href='$image->url'>";
  echo "<img src='$thumb->url' alt='$image->description' />";
  echo "</a>";
}

You can use the above code to create the thumbnails outside a page load if you wish. Have a look at the docs here: https://processwire.com/api/ref/pageimage/

 

Edited by kongondo
  • Like 2

Share this post


Link to post
Share on other sites
On 3/8/2019 at 6:42 PM, kongondo said:

I think you mean 0x260. That is generated automatically by ProcessWire for backend use. You can create your own (other sizes) like shown below. This code goes into your template file.


// Example of outputting a thumbnail gallery of Pageimage objects
foreach($page->images as $image) {
  // $image and $thumb are both Pageimage objects
  $thumb = $image->size(250, 200);// width x height
  echo "<a href='$image->url'>";
  echo "<img src='$thumb->url' alt='$image->description' />";
  echo "</a>";
}

You can use the above code to create the thumbnails outside a page load if you wish. Have a look at the docs here: https://processwire.com/api/ref/pageimage/

This is exactly what I am trying to do.
Create image variations outside a page load, so not inside the template file but during the initial upload process in the backed/admin panel when then thumbnail is generated.

Had a look at the docs you like for the Pageimage class but I am not sure how to use that info.
Reading through this https://selftaughtcoders.com/from-idea-to-launch/lesson-14/how-to-use-classes-in-php/ and then for example inserting

<?php

$galleryImg = new Pageimage;

$defaultOptions = array(
	'upscaling' => false,
	'cropping'  => false,
	'quality'   => 90,
);

$galleryImg->size(1280, 0, $defaultOptions);

into _func.php of the Intermediate profile does not create the desired 1200px width image variation.
Would be super grateful to learn how I can generate image variations during the initial upload process in the admin panel.
Thank you.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...