rushy Posted November 29, 2021 Share Posted November 29, 2021 Hi to everyone. I have created an online photo album using PW and I have a front end implementation to upload images into my albums. The problem I encounter is if / when I log in to the backend and view any album there are potentially several thousand images in each album and PW then generates it's default image thumbnails which effectively times out my request and also generates thousands of unwanted thumbnails. How can I tweak things so these do not get created? Just wondered if it's possible to change this default behaviour. Many thanks Link to comment Share on other sites More sharing options...
Zeka Posted November 29, 2021 Share Posted November 29, 2021 Hi @rushy AFAK there is no built-in option. There is a way how you can override core modules https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-copies-of-the-same-module. After that you can adopt 'getAdminThumb' method so your default image variation will match one that you are using on the frontend. Potentially there could be some issues with admin UI. 2 Link to comment Share on other sites More sharing options...
horst Posted November 29, 2021 Share Posted November 29, 2021 Hi @rushy, you also first may try to set the $config->adminThumbOptions in a way that matches already existing image variations: Quote /** * Admin thumbnail image options * * Controls the output of the thumbnail images used in image fields presented in the admin. * * #property int width Width of thumbnails or 0 for proportional to height (default=0). * #property int height Height of thumbnails or 0 for proportional to width (default=100). * #property float scale Width/height scale (1=auto detect, 0.5=always hidpi, 1.0=force non-hidpi) * #property bool upscaling Upscale if necessary to reach target size? (1=true, 0=false). * #property bool cropping Crop if necessary to reach target size? (1=true, 0=false). * #property bool autoRotation Automatically correct orientation? (1=true, 0=false). * #property string sharpening Sharpening mode, enter one of: none, soft, medium, strong (default=soft). * #property int quality Image quality, enter a value between 1 and 100, where 100 is highest quality, and largest files (default=90). * #property string suffix Suffix to append to all thumbnail images (1-word of a-z 0-9, default=blank) * * @var array * */ $config->adminThumbOptions = array( 'width' => 0, // max width of admin thumbnail or 0 for proportional to height (@deprecated, for legacy use) 'height' => 100, // max height of admin thumbnail or 0 for proportional to width (@deprecated, for legacy use) 'gridSize' => 130, // Squared grid size for images (replaces the 'width' and 'height' settings) 'scale' => 1, // admin thumb scale (1=allow hidpi, 0.5=always hidpi, 1.0=force non-hidpi) 'upscaling' => false, 'cropping' => true, 'autoRotation' => true, // automatically correct orientation? 'sharpening' => 'soft', // sharpening: none | soft | medium | strong 'quality' => 90, 'suffix' => '', ); Above are the default settings from the wire/config.php. Use this as starting point and copy it into your site/config.php and adjust as needed. Link to comment Share on other sites More sharing options...
rushy Posted November 29, 2021 Author Share Posted November 29, 2021 Thank you Zeka and horst. I will try the $config->adminThumbOptions that you suggested horst. I am using proportional thumbnails and I note it's now deprecated in admin. I set a fixed height and calculate a scaling factor for proportional width as in the function below. It seems to work ok but I'm not sure it's the best way to tackle this. function getScaledThumbNail($image) { $justHt = wire('pages')->get('/')->gal_just_row_height; $scale = $image->height / $justHt; if($scale <= 0) { $thumb = null; }else { $tnW = $image->width / $scale; $thumb = $image->size($tnW, $justHt); } return $thumb; } Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now