MyBB Hacks

Full Version: Only keep thumbnail and erase original image ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,


I have a xthread field type image, i use

"Image Thumbnail Generation"
350x350

"Display Format"
<img src="{URL}/thumb350x350" alt="{FILENAME}" title="{FILENAME}" style="margin: 3px; " />

I'm using a lot of thumbnails but never the original file. To save space, I'd like to prevent the original from being saved on disk but only keep a thumbnail of 350px.

A way to this automatically without intervening manually ?
It won't ever be supported, because it would break stuff like rebuild thumbnails (meaning you're stuck with whatever thumbnail you generate).

If you absolutely must have it though, maybe try this code edit (I have not tested it so don't know if it works - please test it before using it).
In inc/xthreads/xt_upload.php, find

PHP Code:
	if(!empty($img_dimensions) && !empty($tf['fileimgthumbs'])) {
		// generate thumbnails
		$attacharray['thumbs'] = xthreads_build_thumbnail($tf['fileimgthumbs'], $attacharray['aid'], $tf['field'], $new_file, $path, $month_dir, $img_dimensions);
		$attacharray['thumbs']['orig'] = $origdimarray;
		$attacharray['thumbs'] = serialize($attacharray['thumbs']);
	}
	
	return $attacharray;

Replace with

PHP Code:
	if(!empty($img_dimensions) && !empty($tf['fileimgthumbs'])) {
		// generate thumbnails
		$attacharray['thumbs'] = xthreads_build_thumbnail($tf['fileimgthumbs'], $attacharray['aid'], $tf['field'], $new_file, $path, $month_dir, $img_dimensions);
		$attacharray['thumbs']['orig'] = $origdimarray;
		$attacharray['thumbs'] = serialize($attacharray['thumbs']);
	}
	@unlink($new_file);
	return $attacharray;


It's an ugly hack, and a side effect is that it may still generate junk directories etc, but it solves the space problem at least.

Quote:it would break stuff like rebuild thumbnails (meaning you're stuck with whatever thumbnail you generate).

Hmmm, sure...
Thanks for the modification, i don't use it for the moment...maybe it's a bad idea Ouch
Reference URL's