• Welcome to the Chevereto user community!

    Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.

    Please keep in mind:

    • 😌 This community is user driven. Be polite with other users.
    • 👉 Is required to purchase a Chevereto license to participate in this community (doesn't apply to Pre-sales).
    • 💸 Purchase a Pro Subscription to get access to active software support and faster ticket response times.
  • Chevereto Support CLST

    Support response

    Support checklist

Thumb size medium just if original img size is greater than 600px width

vlaur

Chevereto Member
Hi,

How can this function to be applied just if original picture have width size more or equal with 600px.

For example I have set medium thumb to 320px width, but some users is uploading image at 400px so to make 320px medium thumb for an image by 400px is an waste of space so i want to limit it just for images large than 600px.

This is a question! if someone can help please reply.
 
Check the app/routes/route.json.php file. You can clone this file into the overrides folder and do all your special coding there without affecting the core. The system has a conditional where it does something pretty similar of what you want to do. Search for case 'upload'
 
Check the app/routes/route.json.php file. You can clone this file into the overrides folder and do all your special coding there without affecting the core. The system has a conditional where it does something pretty similar of what you want to do. Search for case 'upload'
Thank you,

Final code:
PHP:
                $is_animated_image = $image_upload['uploaded']['fileinfo']['extension'] == 'gif' and G\is_animated_image($image_upload['uploaded']['file']);
                $extend_msize = 600;
                if($image_upload['uploaded']['fileinfo']['width'] > $extend_msize or $image_upload['uploaded']['fileinfo']['height'] > $medium_size or $is_animated_image) {
               
                    $image_medium_options = [];
               
                    if($image_upload['uploaded']['fileinfo']['ratio'] > 1) {
                        $image_medium_options['width'] = $medium_size;
                    } else {
                        $image_medium_options['height'] = $medium_size;
                    }
               
                    if($is_animated_image) {
                        $image_medium_options['forced'] = true;
                    }
               
                    $image_medium = CHV\Image::resize($image_upload['uploaded']['file'], $upload_path, $image_upload['uploaded']['name'] . '.md', $image_medium_options);
                }

I have added a new variable and replaced medium_size for width with this variable ... but somehow work for jpg png but not for gif

From now, no more wasted space.
 
Back
Top