Jump to content

Generating image variants


ZGD
 Share

Recommended Posts

I've been using PW for a few years now and I believe this is the only problem I frequently encounter, although this latest case is particularly relevant. I'm sure there must be a simple solution, but I've yet to work it out.

Thanks to a great collaboration with a member of the community, we have a website (still in development...) that imports data from an external service into PW via a JSON feed. The import process can create hundreds of pages with new images that are saved from URLs specified in the feed. As these can be very high resolution, we use the $image->size() method to resize them to acceptable dimensions.

As this import process is happening constantly in the background, images on certain pages are constantly changing. This means a large number of images may not have variants generated until that page is visited by a user, and that process can take quite a while. Some pages have 50+ images (lazyloaded!).

What is the normal way of solving this problem? I'd considered writing a module that would imitate a user visit to these pages each time they are saved and thus generate the variants. Is there a simpler solution?

Link to comment
Share on other sites

If you only need the images to be created and you know the sizes upfront, then simply call those width functions as part of the import process.

$img = 

// Create thumbs
$img->size(700, 300);
$img->width(200);

 

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