• Welcome to the Chevereto User Community!

    Here, users from all over the world come together to learn, share, and collaborate on everything related to Chevereto. It's a place to exchange ideas, ask questions, and help improve the software.

    Please keep in mind:

    • This community is user-driven. Always be polite and respectful to others.
    • Support development by purchasing a Chevereto license, which also gives you priority support.
    • Go further by joining the Community Subscription for even faster response times and to help sustain this space

Avoid large images to be displayed

makaja2

Chevereto Member
Hi,

When we view image, it alway load original size, some picture with high resolution and big size like 5mb, and it will load very slow, can you add 1 option, only load large size (2048px sound good), and if user want view full size, just download original size.

Thanks
 
Can you share your code?
Yes of couse, why not 😀 this code include Next and Prev button with image don't have album, can you add to next version 😀

app/routes/route.image.php
Code:
<?php

/* --------------------------------------------------------------------

  Chevereto
  http://chevereto.com/

  @author    Rodolfo Berrios A. <http://rodolfoberrios.com/>
            <inbox@rodolfoberrios.com>

  Copyright (C) Rodolfo Berrios A. All rights reserved.
 
  BY USING THIS SOFTWARE YOU DECLARE TO ACCEPT THE CHEVERETO EULA
  http://chevereto.com/license

  --------------------------------------------------------------------- */

$route = function($handler) {
    try {
       
        if($handler->isRequestLevel(3)) return $handler->issue404(); // Allow only 2 levels
       
        if(is_null($handler->request[0])) {
            return $handler->issue404();
        }
       
        $logged_user = CHV\Login::getUser();
       
        // User status override redirect
        CHV\User::statusRedirect($logged_user['status']);

        $id = CHV\decodeID($handler->request[0]);
       
        $tables = CHV\DB::getTables();
       
        if($id==0) {
            return $handler->issue404();
        }

        // Get image DB
        $image = CHV\Image::getSingle($id, true, true);
       
        // No image or belogns to a banned user if exists?
        if(!$image or (!$logged_user['is_admin'] and !is_null($image['user']['status']) and $image['user']['status'] !== 'valid')) {
            return $handler->issue404();
        }
       
        if(!$image['path'] or !file_exists($image['path'])) {
            //CHV\Image::delete($id);
            return $handler->issue404();
        }
       
        $is_admin = $handler::getCond('admin');
        $is_owner = $image['user']['id'] !== NULL ? ($image['user']['id'] == $logged_user['id']) : false;
       
        // Privacy
        if($handler::getCond('forced_private_mode')) {
            $image['album']['privacy'] = CHV\get_chv_setting('website_content_privacy_mode');
        }
        if(!$is_admin and in_array($image['album']['privacy'], array('private', 'custom')) and !$is_owner) {
            return $handler->issue404();
        }
       
        $db = CHV\DB::getInstance();
       
        // User found
        if($image['user']['id'] !== NULL) {
           
            // Get user albums
            $name_array = explode(' ', $image['user']['name']);
            $user_name_short = $name_array[0];
           
            $image['user']['albums'] = [];
           
            // Lets fake the stream as an album
            $image['user']['albums']['stream'] = CHV\User::getStreamAlbum($image['user']);
           
            // Get user album list
            $image['user']['albums'] += CHV\DB::get('albums', ['user_id' => $image['user']['id']], 'AND', ['field' => 'date', 'order' => 'asc']);
           
            foreach($image['user']['albums'] as $k => $v) {
                $image['user']['albums'][$k] = CHV\DB::formatRow($v, 'album');
                CHV\Album::fill($image['user']['albums'][$k]);
            }
           
        }

        // Get the album slice
        if($image['album']['id'] !== NULL) {
            $get_album_slice = CHV\Image::getAlbumSlice($image['id'], $image['album']['id'], 2);
            $image_album_slice_db = $get_album_slice['db'];
            $image_album_slice = array_merge($image['album'], $get_album_slice['formatted']);
        }elseif($image['category_id']){
            $get_album_slice = CHV\Image::getCategorySlice($image['id'], $image['category_id'], 2);
            $image_album_slice = $get_album_slice['formatted'];
        }else{
            $image_album_slice['next'] = array('url_viewer' => G\get_base_url("?random") );
        }
       
        $image_safe_html =  G\safe_html($image);
       
        $pre_doctitle = $image_safe_html['description'] ? $image_safe_html['description'] : ($image_safe_html['name'].'.'.$image_safe_html['extension']) . ' hosted at ' . CHV\get_chv_setting('website_name');
       
        $handler::setVar('pre_doctitle', $pre_doctitle);
        $handler::setCond('owner', $is_owner);
        $handler::setVar('image_album_slice_db', $image_album_slice_db);
        $handler::setVar('image', $image);
        $handler::setVar('image_safe_html', $image_safe_html);
        $handler::setVar('image_album_slice', G\safe_html($image_album_slice));
       
        // Populate image category to meta keywords
        $category = $handler::getVar('categories')[$image['category_id']];
        if($category) {
            $handler::setVar('meta_keywords', _s('%s images', $category['name']) . ', ' . $handler::getVar('meta_keywords'));
        }
       
        // Populate the image meta description
        if($image['description']) {
            $handler::setVar('meta_description', htmlspecialchars($image['description']));
        }
       
        // Trail this view
        $_SESSION['last_viewed_image'] = CHV\encodeId($id);

    } catch(Exception $e) {
        G\exception_to_error($e);
    }
};
 
I think that large images should be stored as .original and enable access to it by download button (no embed code). Finally if someone want to directly access that image it will be forced to download.
 
Please add an option to disable this from the administrator dashboard.
We don't even feature this "big" size and .original image. You are asking for something that doesn't exists and if it does, take for sure that it will be configurable.
 
We don't even feature this "big" size and .original image. You are asking for something that doesn't exists and if it does, take for sure that it will be configurable.

I might be talking about the wrong item. In versions prior to 3.8x, clicking a medium thumb embedded would take the user to the full-resolution image without a need for any more clicks. Some of us don't care about bandwidth 🙂
 
Back
Top