Thumbnails...need help please.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
meduser
Forum Newbie
Posts: 20
Joined: Mon Apr 09, 2012 12:08 pm

Re: Thumbnails...need help please.

Post by meduser »

hmm..still can't get it to go..what could I be doing wrong?

I don"t get it..
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Thumbnails...need help please.

Post by Celauran »

I certainly can't guess. What can't you get going, exactly?
User avatar
meduser
Forum Newbie
Posts: 20
Joined: Mon Apr 09, 2012 12:08 pm

Re: Thumbnails...need help please.

Post by meduser »

I have the createThumbs.php file and the thumbnail.inc.php file in the main folder of my project. The image folder is right there.

For example:
/var/www/Final3/createThumbs.php
/var/www/Final3/thumbnail.inc.php
images are at:
/var/www/Final3/images/

I have typed into my browser(Chrome) http://localhost/Final3/createThumbs.php

I get a white screen with an error:
the website encountered an error.

If I go to localhost/Final3/index.php I get my frontpage, and can browse the site.

My image folder does not change when typing in

http:// localhost/Final3/createThumbs.php

I just don't get what I am doing wrong. I have created guis and how to's for other things, way more complicated than this, and still, here I am..lol
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Thumbnails...need help please.

Post by Celauran »

Do you have error reporting on? That's a particularly worthless error message. Did you at least get an error code?
User avatar
meduser
Forum Newbie
Posts: 20
Joined: Mon Apr 09, 2012 12:08 pm

Re: Thumbnails...need help please.

Post by meduser »

what kind of response am I supposed to get? I breakdown of the pics?I moved thecreateThumb.php to here:

Code: Select all

<?php

require_once('thumbnail.inc.php');

/**
 * Create thumbnail images for the images directory!
 */
 function createThumbs() {
		
	$pathName = dirname(__FILE__) . '/images/';
		
	// create an array containing the list of thumbnails 
	// this will be passed from the controller to the view
	$thumbFiles = array();


	// DirectoryIterator is part of the Standard PHP library	
	foreach(new DirectoryIterator($pathName) as $fileInfo) {
			
		$fileName = $fileInfo->getFileName();
		
		if ($fileInfo->isDir()) {
			continue;
		}
			
		// TODO: we should also check if this file 
		// already has a thumbnail generated!!
		
		// skip thumbnails that have already been generated
		//			
		$pos = strpos($fileName, "_Thumb.");
		if ($pos !== false) {
			//$thumbFiles[] = $thumbFileName;	
			continue;	
		}
			
		$thumb = new Thumbnail($pathName . $fileName);
		$thumb->resize(200, 100);
      		
		// create a new fileName with 'Small' in it 
		// (e.g. pic.jpg -> picSmall.jpg)
		//
		$thumbFileName = 
		substr_replace($fileName, "_Thumb", strpos($fileName, '.'));
			
		// add the file extension back
		$thumbFileName .= '.' . substr($fileName, -3);
		 
		$thumb->save($pathName . $thumbFileName);
			
		// add this to our array containing the list of thumbnail files
		$thumbFiles[] = $thumbFileName;	
			
		//echo $fileInfo . "\n";
	}
	return $thumbFiles;
	createThumbs();
}

?>
Is that right? I get just a white screen, no error with it sitting there. No thumbnails either.
If I move the createThumbs.php to below the ?> I get just createThumbs() on a white page, but again, no thumbnails..???
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Thumbnails...need help please.

Post by Celauran »

No, you've got the function call inside the function definition. Move it outside the last closing brace but inside the closing PHP tag.

Code: Select all

function createThumbs()
{
    // Lots of stuff here
}
createThumbs();

?>
User avatar
meduser
Forum Newbie
Posts: 20
Joined: Mon Apr 09, 2012 12:08 pm

Re: Thumbnails...need help please.

Post by meduser »

ok..I have moved that, now I get error: unknown file format in the top left of the browser and that is it. Everything in my images folder is a jpeg.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Thumbnails...need help please.

Post by Celauran »

Doesn't say which file it choken on? Did it create any thumbs at all? Have you checked for dotfiles?
User avatar
meduser
Forum Newbie
Posts: 20
Joined: Mon Apr 09, 2012 12:08 pm

Re: Thumbnails...need help please.

Post by meduser »

No it just said error: unknown file format
The website encountered an error while retrieving http://localhost/Final3/createThumbs.php. It may be down for maintenance or configured incorrectly.
User avatar
meduser
Forum Newbie
Posts: 20
Joined: Mon Apr 09, 2012 12:08 pm

Re: Thumbnails...need help please.

Post by meduser »

I have checked with the terminal for hidden files, and nothing..
litebearer
Forum Contributor
Posts: 194
Joined: Sat Mar 27, 2004 5:54 am

Re: Thumbnails...need help please.

Post by litebearer »

Not to further confuse the OP; however, http://www.binarymoon.co.uk/projects/timthumb/
Post Reply