novafacile / novagallery

novaGallery - a beautiful and and ease to use php image gallery for your photos - flat file - no database required - modern responsive design
https://novagallery.org
GNU Affero General Public License v3.0
74 stars 11 forks source link

How to don't create imageSizeBig ? #46

Open Zatalyz opened 10 months ago

Zatalyz commented 10 months ago

Hello, Thanks for your great code, it's very nice.

I have a problem: when I click on an image (to see it on the lightbox), it creates an image with the dimensions indicated in "Site.php", in the "imageSizeBig" parameter. And so, this fills the cache folder.

I don't want to generate a new version of the image here, but just display the image stored in my source folder, whether it's really too small or really too big.

Is there a way to have this behaviour?

keusendev commented 8 months ago

Hi

I have the same issue. All the images are already in an optimized format. I very much like to see an option to disable this behaviour 👍.

BTW great and simple gallery ❤️. We also supported the project/product by buying the Pro version 😃.

awong234 commented 7 months ago

I think I've solved it:

In nova-themes/novagallery/album.php, around line 36, modify the code so that the image link itself does not have pass a $size argument:

<a href="<?php echo Image::url($album, $element); ?>"> <!-- <------------ here remove the Site::config('imageSizeBig') argument -->
  <img src="<?php echo Image::url($album, $element, Site::config('imageSizeThumb')); ?>" loading="lazy" class="rounded"><br>
</a>

Do the same in the nova-themes/novagallery/home.php file.

Then, in nova-base/lib/image.php, modify the lines around 83-89:

$url = IMAGES_URL.'/'.$album.'/'; <!-- Changed so that it does not point to cache -->

if($size){
  $url = IMAGES_URL.'/'.$album.'/cache/'; <!-- Points to cache here -- it really only needs to do this for the thumbnails, or if the user actually wants to cache an imageSizeBig config  -->
  $url .= $size.'/';
}

I don't have a pull request out yet, because I think it can be handled better at the site config level. For instance, if imageSizeBig: 'original' is set (or something like that) , then the code can test against that and handle whether to add the 'cache' to the URL or not.